On Wednesday, 2 November 2016 at 03:36:42 UTC, Andrei
Alexandrescu wrote:
Last time I looked our associative arrays were arrays of
singly-linked lists. It follows that in order to implement
reserve() we'd need a freelist allocator approach, which
preallocates a bunch of nodes in a single contiguous block of
memory.
Aren't associative arrays using open addressing for collision
resolution? I'm looking at routines findSlotInsert() and
findSlotLookup() here:
https://github.com/dlang/druntime/blob/master/src/rt/aaA.d#L102
There is already a resize() routine:
https://github.com/dlang/druntime/blob/master/src/rt/aaA.d#L141
The resize() routine takes the new size of the bucket array as an
argument. Could a 'reserve' routine call this? Scanning through
the code, it appears policy on size of the bucket array is
established by callers to resize(), e.g. see the _aaRehash()
function, which calls resize().