Avoid using string operator += for a single character (#7747)

This is flagged as a mistake by clang-tidy 24. String's operator `+=` is
pretty bad in general, this moves a few uses to push_back.
This commit is contained in:
Dana Jansens
2026-09-10 16:39:08 +00:00
committed by GitHub
parent c24adea6fe
commit c6c40cc444
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -150,12 +150,12 @@ class StringFingerprintStore {
bool first = true;
for (const auto& item : contents_) {
if (!first) {
result += ",";
result.push_back(',');
}
first = false;
result += item;
}
result += "}";
result.push_back('}');
return SaveString(std::move(result));
}
+1 -1
View File
@@ -409,7 +409,7 @@ auto InstNamer::Namespace::AllocateName(
}
// Append numbers until we find an available name.
name += ".";
name.push_back('.');
auto name_size_without_counter = name.size();
for (int counter = 1;; ++counter) {
name.resize(name_size_without_counter);