[llvm] [llvm-remarkutil] Simplify code with std::map::operator[] (NFC) (PR #111407)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 18:37:53 PDT 2024
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/111407
>From bc7831a7b481ad75267ee8eefe195f19e2b3edf8 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 7 Oct 2024 10:09:06 -0700
Subject: [PATCH] [llvm-remarkutil] Simplify code with std::map::operator[]
(NFC)
---
llvm/tools/llvm-remarkutil/RemarkCounter.cpp | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/llvm/tools/llvm-remarkutil/RemarkCounter.cpp b/llvm/tools/llvm-remarkutil/RemarkCounter.cpp
index dc0685f342886a..2d9432e41d9c06 100644
--- a/llvm/tools/llvm-remarkutil/RemarkCounter.cpp
+++ b/llvm/tools/llvm-remarkutil/RemarkCounter.cpp
@@ -198,12 +198,8 @@ void ArgumentCounter::collect(const Remark &Remark) {
}
void RemarkCounter::collect(const Remark &Remark) {
- std::optional<std::string> Key = getGroupByKey(Remark);
- if (!Key.has_value())
- return;
- auto Iter = CountedByRemarksMap.insert({*Key, 1});
- if (!Iter.second)
- Iter.first->second += 1;
+ if (std::optional<std::string> Key = getGroupByKey(Remark))
+ ++CountedByRemarksMap[*Key];
}
Error ArgumentCounter::print(StringRef OutputFileName) {
More information about the llvm-commits
mailing list