[llvm] [TableGen] Avoid repeated hash lookups (NFC) (PR #126433)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 9 11:47:14 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-tablegen
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/126433.diff
1 Files Affected:
- (modified) llvm/utils/TableGen/Common/CodeGenSchedule.cpp (+3-3)
``````````diff
diff --git a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
index e84b4fd77a6c1fe..8e8b3196c91b01d 100644
--- a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
@@ -413,9 +413,9 @@ void CodeGenSchedModels::collectSTIPredicates() {
for (const Record *R : Records.getAllDerivedDefinitions("STIPredicate")) {
const Record *Decl = R->getValueAsDef("Declaration");
- const auto It = Decl2Index.find(Decl);
- if (It == Decl2Index.end()) {
- Decl2Index[Decl] = STIPredicates.size();
+ const auto [It, Inserted] =
+ Decl2Index.try_emplace(Decl, STIPredicates.size());
+ if (Inserted) {
STIPredicateFunction Predicate(Decl);
Predicate.addDefinition(R);
STIPredicates.emplace_back(std::move(Predicate));
``````````
</details>
https://github.com/llvm/llvm-project/pull/126433
More information about the llvm-commits
mailing list