[PATCH] D135119: [scudo] Optimize scudo test string allocation
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 11:15:27 PST 2022
vitalybuka 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);
----------------
ddcc wrote:
> 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.
lgtm
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