JesperAxelsson / rust-intmap

Specialized hashmap for u64 keys
MIT License
30 stars 12 forks source link

Memory allocation in `IntMap::new` #49

Closed jakoschiko closed 2 months ago

jakoschiko commented 3 months ago

Hi!

Currently IntMap::new is allocating memory by default. Even IntMap::with_capacity(0) seems to allocate some memory.

The collections of stdlib don't do this:

This is useful if the IntMap<V> has a high probability to remain empty. However, one can use Option<IntMap<V>> as a workaround.

Would it be feasible to change this?

jakoschiko commented 3 months ago

Another benefit: This would allow to make IntMap::new const.

JesperAxelsson commented 2 months ago

I don't work actively on this project anymore. If you want to fix you are welcome to. I can of course review your code when your done. Please avoid using unsafe code though :)