4 ms·
"The C++ version has no pointers but instead uses value types. This means that all data is stored twice: once in the array and a second time in the hash table."
by 72deluxe 9y ago
"The C++ version has no pointers but instead uses value types. This means that all data is stored twice: once in the array and a second time in the hash table."
This is interesting. Are they using modern C++ and making use of moves and perfect forwarding? Or are they just throwing std::strings around and doing millions of copies (e.g. remember std::vector must support copyconstructable, so copy constructors & operator=) in the process? That would explain the allocations in C++ being higher perhaps, particularly if they're using the "wrong" containers. Why not sure unique_ptr or shared_ptr?
It is worth remembering that move constructors and assignment operators only get used in very specific places and you have to ensure that any constructors you write yourself are explicitly noexcept.