[clang] [TableGen] Avoid repeated hash lookups (NFC) (PR #108736)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 15 00:06:40 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/108736.diff
1 Files Affected:
- (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (+2-4)
``````````diff
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 9b2249ac90bc5c..637484149d4438 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -203,12 +203,11 @@ static ParsedAttrMap getParsedAttrList(const RecordKeeper &Records,
// If this attribute has already been handled, it does not need to be
// handled again.
- if (Seen.find(AN) != Seen.end()) {
+ if (!Seen.insert(AN).second) {
if (Dupes)
Dupes->push_back(std::make_pair(AN, Attr));
continue;
}
- Seen.insert(AN);
} else
AN = NormalizeAttrName(Attr->getName()).str();
@@ -1824,10 +1823,9 @@ CreateSemanticSpellings(const std::vector<FlattenedSpelling> &Spellings,
// reserved namespace, we may have inadvertently created duplicate
// enumerant names. These duplicates are not considered part of the
// semantic spelling, and can be elided.
- if (Uniques.find(EnumName) != Uniques.end())
+ if (!Uniques.insert(EnumName).second)
continue;
- Uniques.insert(EnumName);
if (I != Spellings.begin())
Ret += ",\n";
// Duplicate spellings are not considered part of the semantic spelling
``````````
</details>
https://github.com/llvm/llvm-project/pull/108736
More information about the cfe-commits
mailing list