On Thu, Jun 25, 2015 at 3:22 PM, Nico Weber <
tha...@chromium.org> wrote:
> On Thu, Jun 25, 2015 at 2:47 PM, 'Antoine Labour' via Chromium-dev
> <
chromi...@chromium.org> wrote:
>>
>>
>>
>> On Thu, Jun 25, 2015 at 2:00 PM, Brett Wilson <
bre...@chromium.org> wrote:
>>>
>>> If you have a good reason, it's great to use a hash map. But we should
>>> default to regular maps without a good reason. Hashing functions are more
>>> commonly implemented on objects and much easier to screw up than operator<.
>>> And for some workloads they're actually slower and can use more memory.
>>
>>
>> I disagree :) You should use hash maps by default, and only use maps if
>> you actually need ordering of keys.
>> Hash maps use less memory almost always (the per-node overhead is 2
>> pointers instead of 3 pointers + a bool) and lookups are not only faster
>> themselves, but also don't pollute your data cache because of the tree
>> traversal required for the map. That's especially bad if the operator< is
>> expensive (e.g. strings).
>
>
> Meh, std::unsorted_map is pretty slow for a hash map, due to its generality.
> If perf matters, you probably want to roll your own, and if it doesn't
> matter it doesn't matter.
Clearly we should be using WTF::HashMap instead. ;)