How Appender calculate cash size?
Suliman via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Sep 6 12:00:02 PDT 2017
If I right understand Appender and ~ have buffers to minimize
allocations.
"Appender's local capacity storage will give you a pretty big
boost" (с) Adam
"Appender maintains its own array metadata locally, so it can
avoid global locking for each append where capacity is non-zero."
(с) Docs
So if I right understand appender reserve more to prevent
unneeded allocations.
It's seems that here is calculation new size
https://github.com/dlang/phobos/blob/master/std/array.d#L3163
So it's allocate more memory that needed, but I can't understand
it's algorithm. Who could explain how it's work on low level?
How it's make decision how much memory needed to be pre-allocated
to minimize allocations?
More information about the Digitalmars-d-learn
mailing list