Function rt.lifetime.newCapacity
Given an array of length size
that needs to be expanded to newlength
,
compute a new capacity.
ulong newCapacity(
ulong newlength,
ulong elemsize
);
Better version by Dave Fladebo, enhanced by Steven Schveighoffer: This uses an inverse logorithmic algorithm to pre-allocate a bit more space for larger arrays. - The maximum "extra" space is about 80% of the requested space. This is for PAGE size and smaller. - As the arrays grow, the relative pre-allocated space shrinks. - Perhaps most importantly, overall memory usage and stress on the GC is decreased significantly for demanding environments. - The algorithm is tuned to avoid any division at runtime.
Parameters
Name | Description |
---|---|
newlength | new
|
elemsize | size of the element in the new array |
Returns
new capacity for array
Authors
Walter Bright, Sean Kelly, Steven Schveighoffer
License
Distributed under the Boost Software License 1.0. (See accompanying file LICENSE)