When the underlying vector becomes full, it resizes, remaps, and then copies over the old data. To avoid thes excess allocations, allow reservation from the backing vector.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/scudo/standalone/string_utils.h | ||
---|---|---|
22 | I don't like inconsistency with std:: or even Vector<> here 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() : ""; } |
compiler-rt/lib/scudo/standalone/string_utils.h | ||
---|---|---|
22 | 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. |
compiler-rt/lib/scudo/standalone/string_utils.h | ||
---|---|---|
22 | lgtm |
compiler-rt/lib/scudo/standalone/string_utils.h | ||
---|---|---|
31 |
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.