September 06, 2017 How Appender calculate cash size? | ||||
---|---|---|---|---|
| ||||
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? |
Copyright © 1999-2021 by the D Language Foundation