On Mon, Jul 10, 2023 at 09:30:57AM +0000, IchorDev via Digitalmars-d-learn wrote: [...] > From the spec it sounds as though (but good luck testing for sure) > that if you have (for example) 6 big dummy key-value pairs in the AA > to begin with, then if you use `.clear` it "Removes all remaining keys > and values from [the] associative array. The array is not rehashed > after removal, __to allow for the existing storage to be reused.__" [...]
This is not an accurate understanding of what actually happens. The AA implementation consists of a primary hashtable (an array), each slot of which points to a list of buckets. Clearing the AA does not discard the hashtable, but does dispose of the buckets, so adding new keys afterwards will allocate new buckets. So the buckets used by the dummy key-value pairs do not get reused without a reallocation. T -- This is a tpyo.