[clang] [clang][builtins] Return a `SmallString` from `Builtin::Context::getQuotedName()` (PR #227963)
Chandler Carruth via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 30 23:17:22 PDT 2026
================
@@ -96,11 +96,13 @@ std::string Builtin::Context::getName(unsigned ID) const {
return I.getName(Shard);
}
-std::string Builtin::Context::getQuotedName(unsigned ID) const {
+SmallString<64> Builtin::Context::getQuotedName(unsigned ID) const {
const auto &[Shard, I] = getShardAndInfo(ID);
- return (Twine("'") + Shard.NamePrefix + (*Shard.Strings)[I.Offsets.Name] +
- "'")
- .str();
+ SmallString<64> Result("'");
+ Result += Shard.NamePrefix;
+ Result += (*Shard.Strings)[I.Offsets.Name];
+ Result += '\'';
----------------
chandlerc wrote:
Could we use a twine or `formatv` here so that we compute the final size before initializing it? Or does this end up being faster in practice?
https://github.com/llvm/llvm-project/pull/227963
More information about the cfe-commits
mailing list