[PATCH] D135119: [scudo] Optimize scudo test string allocation

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 15:14:05 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);
----------------
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() : ""; }
```


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