News for hackers. Stuff that matters.
Re:Why Hashbrown Does a Double Lookup by Sharlin on Wednesday March 20, 2019 @03:53PM (#19446153)
But surely Rust hashtables just store the objects in the table itself? Rust has value semantics, after all. No indirections unless you opt in and `Box` your objects.
Re:Why Hashbrown Does a Double Lookup by wahern on Wednesday March 20, 2019 @03:58PM (#19446218)
AFAIU it depends on the object and its traits. I'm curious how Rust's hash tables are used in practice, i.e. whether the common use case is copying vs taking ownership of the object itself. Though either way what really matters is whether indirection is required to verify the key (e.g. String).

In C I prefer red-black trees over hash tables because memory management is easier, you get smooth performance characteristics (no resize hiccups), and you're immune from computational complexity attacks without sweating over hashing algorithms. But I use intrusive node fields for my trees, and also tend to keep keys (even string keys) internal to the object as well, which substantially closes the cache performance gap.

Re:Why Hashbrown Does a Double Lookup by steveklabnik on Wednesday March 20, 2019 @04:09PM (#19446318)
Ownership is the usual, at least in the ones I’ve seen. Otherwise you have to start reasoning about lifetimes and that’s trickier.