[clang] [clang][builtins] Return a `SmallString` from `Builtin::Context::getQuotedName()` (PR #227963)
Chandler Carruth via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 3 23:47: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:
I was mostly just imagining using `llvm::formatv(...)` to initialize the small string rather than doing it incrementally with `+=`. But let's not let perfection be the enemy of good: ship it.
https://github.com/llvm/llvm-project/pull/227963
More information about the cfe-commits
mailing list