diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2020-04-11 14:40:01 +0200 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2020-04-11 14:54:32 +0200 |
commit | 5ef2cb3df4ce261ec0ec647f38495d2bf32b996e (patch) | |
tree | d00c5f07bb404e32e1729dc2f27f888d422c5a22 /llvm/lib/Support/FormatVariadic.cpp | |
parent | 512600e3c0db5e78aa5d23cc9efdec86814ca66d (diff) | |
download | llvm-5ef2cb3df4ce261ec0ec647f38495d2bf32b996e.zip llvm-5ef2cb3df4ce261ec0ec647f38495d2bf32b996e.tar.gz llvm-5ef2cb3df4ce261ec0ec647f38495d2bf32b996e.tar.bz2 |
[FormatVariadic] Reduce allocations
- Move Adapters array to the stack, we know the size precisely
- Parse format string on demand into a SmallVector. In theory this could
lead to parsing it multiple times, but I couldn't find a single instance
of that in LLVM.
- Make more of the implementation details private.
Diffstat (limited to 'llvm/lib/Support/FormatVariadic.cpp')
-rw-r--r-- | llvm/lib/Support/FormatVariadic.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Support/FormatVariadic.cpp b/llvm/lib/Support/FormatVariadic.cpp index 0d61fae..632e879 100644 --- a/llvm/lib/Support/FormatVariadic.cpp +++ b/llvm/lib/Support/FormatVariadic.cpp @@ -141,9 +141,9 @@ formatv_object_base::splitLiteralAndReplacement(StringRef Fmt) { return std::make_pair(ReplacementItem{Fmt}, StringRef()); } -std::vector<ReplacementItem> +SmallVector<ReplacementItem, 2> formatv_object_base::parseFormatString(StringRef Fmt) { - std::vector<ReplacementItem> Replacements; + SmallVector<ReplacementItem, 2> Replacements; ReplacementItem I; while (!Fmt.empty()) { std::tie(I, Fmt) = splitLiteralAndReplacement(Fmt); |