string hash significant speedup

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 14 05:50:09 PDT 2017


On 8/10/17 5:10 PM, Johnson Jones wrote:
> On Thursday, 10 August 2017 at 20:07:35 UTC, Steven Schveighoffer wrote:
>> On 8/10/17 3:36 PM, Johnson Jones wrote:
>>> when using T[string], hashing is used. Computing the hash is 
>>> slow(relatively speaking).
>>>
>>> Does D cache the hashes? Strings are immutable so there is absolutely 
>>> no reason why the hash ever need to be computed more than once.
>>
>> It computes them on insertion, and caches the result in the structure 
>> of the hash table.
>>
> 
> Thanks. What is the cache size?

size_t.sizeof

https://github.com/dlang/druntime/blob/master/src/rt/aaA.d#L173

-Steve


More information about the Digitalmars-d-learn mailing list