[PATCH] D135119: [scudo] Optimize scudo test string allocation
Dominic Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 1 20:19:15 PST 2022
ddcc added inline comments.
================
Comment at: compiler-rt/lib/scudo/standalone/string_utils.h:22
+ explicit ScopedString() { init(); }
+ explicit ScopedString(uptr Size) {
+ String.reserve(Size + 1);
----------------
vitalybuka wrote:
> I don't like inconsistency with std:: or even Vector<> here
> the Size argument is expected to be the new size of the container, not reserved size.
>
> ```
> It the optimization is important, I would prefer something like:
> explicit ScopedString() = default;
> uptr length() { return Max(String.size(), 1) - 1; }
> const char *data() { return String.size() ? String.data() : ""; }
> ```
How about just exposing the `reserve` method of the underlying container then? Where the reserved size is always incremented by one to account for the terminator.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135119/new/
https://reviews.llvm.org/D135119
More information about the llvm-commits
mailing list