[clang] [NFC][Clang] Use range for loops in ClangDiagnosticsEmitter (PR #115573)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 12 08:18:05 PST 2024
================
@@ -1553,15 +1526,13 @@ static void emitDiagSubGroups(std::map<std::string, GroupInfo> &DiagsInGroup,
RecordVec &GroupsInPedantic, raw_ostream &OS) {
OS << "static const int16_t DiagSubGroups[] = {\n"
<< " /* Empty */ -1,\n";
- for (auto const &I : DiagsInGroup) {
- const bool IsPedantic = I.first == "pedantic";
-
- const std::vector<std::string> &SubGroups = I.second.SubGroups;
+ for (auto const &[Name, Group] : DiagsInGroup) {
----------------
erichkeane wrote:
Yep, agree. This is a big enough one to use a reference. In general, the `reference vs copy` when there are reasonably trivial copy operations, is roughly 2x ptr size. At this point, I think we're beyond that line (plus have sufficiently non-trivial copy operations), so a reference is valuable here.
I was perhaps a touch comment-happy/didn't look as closely on this one after seeing the previous one.
https://github.com/llvm/llvm-project/pull/115573
More information about the cfe-commits
mailing list