- `vec.capacity`, getter for the amount of space allocated
- `vec.shrinkToFit` (like `std::vector::shrink_to_fit`) this downsize the allocation to keep only
`vec[0..length]` results. Such a minimal allocation avoids any memory waste.!T
In normal times, the memory waste of Vec!T was minimized from 30% to 23% in case of growth.
`Vec!T` now have two ways to resize in case of growth/pushBack:
- Either it's due to some kind of .pushBack and the new capacity follow a sophisticated capacity, tuned with benchmarks.
Growth factor is 3 below 4096 bytes
Growth factor is around 1.62 after 4096 bytes.
This helps balance both memory waste and pushBack times.
- Or it's `vec.resize()` and the new capacity is `max(oldCapacity, given)`
This waste also do not happen for Vec that are allocated with `vec.resize(size_t exact)`.
It used to give twice the capacity needed, now gives exactly the capacity asked for.
**Important:** a `Vec!T` never allocates down, unless shrinkToFit is called.
This is exactly the same behaviour as `std::vector` from MSVCRT.
Assets
2
-
2023-11-06T12:34:55Z
-
2023-11-06T12:34:55Z
-