-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parametrize RawTable, HashSet and HashMap over an allocator #133
Conversation
* `RawTable` has a new type parameter, `A: Alloc + Clone` * When the `nightly` flag is passed, `Alloc` will be the trait in `alloc::Alloc`. * On stable, a minimal shim implementation is provided, along with an implementation for the global allocator. * No public APIs changed. * For `HashMap`, everything is monomorphized to the global allocator, and there should be no performance or size overhead.
* Change order of type parameters * Handle null case for `alloc` * Run rustfmt
Ah, and I didn't test the |
Pretty sure the last errors are not my fault |
Yea we're having CI issues due to cross-rs/cross#357. I will merge as soon as this is resolved. |
@Amanieu Regarding your reply in fitzgen/bumpalo#54
Wouldn't this cause problems with API stability? Or were you thinking behind a feature flag? |
I'll just make a major version bump, it's fine. |
Just to add some context as to why this hasn't moved anywhere on my end. I am a bit unsure how to handle things like pub fn union<'a>(&'a self, other: &'a HashSet<T, S>) -> Union<'a, T, S> {
let (smaller, larger) = if self.len() <= other.len() {
(self, other)
} else {
(other, self)
};
Union {
iter: larger.iter().chain(smaller.difference(larger)),
}
} This function takes two sets, which we presumably want the ability to be from two different allocators. Internally it does a compare, and returns a If the two sets are from different allocators, this approach wouldn't work as the returned struct would have a different allocator type parameter depending on which set is larger. I see a couple of different options:
Thoughts? |
I think for now it would be best to stick to the simplest solution, which is to require both |
Again, I don't think the last error is due to my changes |
RawTable
over an allocator
Seems like the allocator trait (AllocRef right now) is under major flux right now in the latest nightlies. I'll update to latest, but I guess it might make sense to wait with merging until things settle a bit? |
Yea we've got a few changes lined up. Ideally I would like to wait until |
I'm fine with using my forks for now. Would you mind dropping a comment when you believe most changes are out of the way and I'll update to latest? |
Sure! Will do. |
This change would make the
RawTable
usable with things like arena allocation.RawTable
has a new type parameter,A: Alloc + Clone
nightly
flag is passed,Alloc
will be the trait inalloc::Alloc
.implementation for the global allocator.
HashMap
, everything is monomorphized to the global allocator,and there should be no performance or size overhead.