[llvm] [ExecutionEngine] Avoid repeated hash lookups (NFC) (PR #128827)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 25 22:21:20 PST 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/128827

None

>From 569dd42828c2a184936edf6008446c82d84b02d2 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 25 Feb 2025 09:09:11 -0800
Subject: [PATCH] [ExecutionEngine] Avoid repeated hash lookups (NFC)

---
 llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
index 17f4c3c741141..9ff12b201a988 100644
--- a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
@@ -484,10 +484,8 @@ COFFPlatform::buildJDDepMap(JITDylib &JD) {
           }
           DM.push_back(KV.first);
           // Push unvisited entry.
-          if (!JDDepMap.count(KV.first)) {
+          if (JDDepMap.try_emplace(KV.first).second)
             Worklist.push_back(KV.first);
-            JDDepMap[KV.first] = {};
-          }
         }
       });
     }



More information about the llvm-commits mailing list