[lld] [wasm] Avoid repeated hash lookups (NFC) (PR #122626)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 11 18:32:51 PST 2025


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

None

>From e684090733fc5801d98fbae3876e745eb4d97244 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 11 Jan 2025 17:55:29 -0800
Subject: [PATCH] [wasm] Avoid repeated hash lookups (NFC)

---
 lld/wasm/SymbolTable.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp
index f57359083d242f..6309cf35fe5523 100644
--- a/lld/wasm/SymbolTable.cpp
+++ b/lld/wasm/SymbolTable.cpp
@@ -1009,8 +1009,8 @@ void SymbolTable::handleWeakUndefines() {
 }
 
 DefinedFunction *SymbolTable::createUndefinedStub(const WasmSignature &sig) {
-  if (stubFunctions.count(sig))
-    return stubFunctions[sig];
+  if (auto it = stubFunctions.find(sig); it != stubFunctions.end())
+    return it->second;
   LLVM_DEBUG(dbgs() << "createUndefinedStub: " << toString(sig) << "\n");
   auto *sym = reinterpret_cast<DefinedFunction *>(make<SymbolUnion>());
   sym->isUsedInRegularObj = true;



More information about the llvm-commits mailing list