Pre-expanding alloc cell(s) / reserving space for an associative array
Cecil Ward
cecil at cecilward.com
Sun Jul 9 20:24:24 UTC 2023
Before I posted a question about avoiding unnecessary
allocs/reallocs when adding entries to an array like so
uint[ dstring ] arr;
when I build it up from nothing with successive insertions.
The array is accessed by a key that is a dstring. I was told that
I can’t use .reserve or the like on it? Is that correct? My
memory fails me, powerful pain drugs.
Is there an alternate method I could use ? To be honest, the
number of entries is likely to be extremely modest, so this is
not a huge performance issue, six entries would be considered
quite a lot. The string keys are probably not very very long. But
I’m learning good habits for the day when I might have a bigger
such database.
More information about the Digitalmars-d-learn
mailing list