[llvm] 53ab564 - [NFC][YAMLTraits] Use `SmallString<>`+SSO when yamlizing non-strings
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 5 10:39:46 PST 2023
Author: Roman Lebedev
Date: 2023-01-05T21:39:04+03:00
New Revision: 53ab564ecfc93984ded8cce26d210af9f828a49c
URL: https://github.com/llvm/llvm-project/commit/53ab564ecfc93984ded8cce26d210af9f828a49c
DIFF: https://github.com/llvm/llvm-project/commit/53ab564ecfc93984ded8cce26d210af9f828a49c.diff
LOG: [NFC][YAMLTraits] Use `SmallString<>`+SSO when yamlizing non-strings
This gets rid of basically all temporary allocations
during YAML serialization of llvm-exegesis snippets,
we go from ~1.8M temporary allocations to 13k.
Added:
Modified:
llvm/include/llvm/Support/YAMLTraits.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h
index e46442d4736f0..ef74f38671b58 100644
--- a/llvm/include/llvm/Support/YAMLTraits.h
+++ b/llvm/include/llvm/Support/YAMLTraits.h
@@ -1000,8 +1000,8 @@ template <typename T>
std::enable_if_t<has_ScalarTraits<T>::value, void> yamlize(IO &io, T &Val, bool,
EmptyContext &Ctx) {
if ( io.outputting() ) {
- std::string Storage;
- raw_string_ostream Buffer(Storage);
+ SmallString<128> Storage;
+ raw_svector_ostream Buffer(Storage);
ScalarTraits<T>::output(Val, io.getContext(), Buffer);
StringRef Str = Buffer.str();
io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));
More information about the llvm-commits
mailing list