[llvm-branch-commits] [llvm] [llvm][mustache] Avoid excessive hash lookups in EscapeStringStream (PR #160166)
Paul Kirth via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 23 10:10:35 PDT 2025
ilovepi wrote:
> In these tests, at which point are you constructing the std::array? Is it inside each EscapeStream or once when Template is constructed?
>
Once when the template is constructed. I used a function w/ a static variable to provide the default escapes.
> It's possible that `std::array` wasn't the right suggestion -- maybe the fact that it stores std::string makes it too large. But if you check what find_first_of actually does
>
> https://github.com/llvm/llvm-project/blob/ebcf1bf2ecba6b25ece3c2bbddb4485e76189387/llvm/lib/Support/StringRef.cpp#L240-L242
>
> it will just take that string of characters you pass it an convert it into a bitset. We may as well directly create the bitset instead of creating the char string and then converting it to a bit set on every call.
Could be. I think the big win is that when we use find_first_of we pass a big stringref to the output stream instead of passing in one string at a time. There's no copy, and the number of iterations where we write to the stream is reduced.
https://github.com/llvm/llvm-project/pull/160166
More information about the llvm-branch-commits
mailing list