Skip to content

Commit 53ab564

Browse files
committed
[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.
1 parent 866c587 commit 53ab564

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/include/llvm/Support/YAMLTraits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,8 +1000,8 @@ template <typename T>
10001000
std::enable_if_t<has_ScalarTraits<T>::value, void> yamlize(IO &io, T &Val, bool,
10011001
EmptyContext &Ctx) {
10021002
if ( io.outputting() ) {
1003-
std::string Storage;
1004-
raw_string_ostream Buffer(Storage);
1003+
SmallString<128> Storage;
1004+
raw_svector_ostream Buffer(Storage);
10051005
ScalarTraits<T>::output(Val, io.getContext(), Buffer);
10061006
StringRef Str = Buffer.str();
10071007
io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));

0 commit comments

Comments
 (0)