Closed quininer closed 11 months ago
I don't see the point of this new method. What advantage does it have over reset
? What do you mean by "keep expected memory size"?
I'm assuming what this does is instead of deallocating all previously allocated chunks other than the first one, it keeps all allocations, allowing you to reuse them when you reuse Bump
. This seems useful to me, since if you're performing a bunch of tasks with similar memory needs, it might make sense to prevent having to fetch chunks from the global allocator over and over again. Would this not be so performant in practice? If not, this PR seems like something I might use in a project I'm working on right now (though I'd have to benchmark it).
This can be used to reserve capacity. Currently, one can only only reserve capacity at the start (by with_capacity
or alloc
+ reset
). With reset_back
, one can reserve needed space by alloc
+ reset_back
in the middle.
This is already the existing behavior of reset
.
This adds another reset method, which is different from reset in that it keeps last chunk on linked list instead of first chunk.
This is helpful for keep expected memory size after reset.