[PATCH] D119177: [demangler] Fix buffer growth
Nathan Sidwell via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 10 04:50:24 PST 2022
urnathan marked an inline comment as done.
urnathan added inline comments.
================
Comment at: libcxxabi/src/demangle/Utility.h:43-45
+ constexpr size_t MinAlloc = 1024;
+ if (!BufferCapacity && Need < MinAlloc)
+ Need = MinAlloc;
----------------
ChuanqiXu wrote:
> It looks like that `MinInitAlloc` is a better name. I would like to move line 43~45 after line 38. Then we could simplify the code to:
> ```
> size_t Need = N + CurrentPosition;
> /// A comment here
> constexpr size_t MinInitAlloc = 1024;
> if (!BufferCapacity)
> Need = max(Need, MinInitAlloc);
> if (Need > BufferCapacity)
> BufferCapacity = max(Need, BufferCapacity * 2);
> ```
I put the MinInitAlloc checking inside the outer if, to avoid making the non-allocating path more complex. We only need to check the minium when we know we're going to allocate
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119177/new/
https://reviews.llvm.org/D119177
More information about the llvm-commits
mailing list