[PATCH] D119177: [demangler] Fix buffer growth
Chuanqi Xu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 9 18:08:55 PST 2022
ChuanqiXu added inline comments.
================
Comment at: libcxxabi/src/demangle/Utility.h:43-45
+ constexpr size_t MinAlloc = 1024;
+ if (!BufferCapacity && Need < MinAlloc)
+ Need = MinAlloc;
----------------
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);
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119177/new/
https://reviews.llvm.org/D119177
More information about the llvm-commits
mailing list