[llvm] 73beb15 - [MC] Avoid repeated hash lookups (NFC) (#123698)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 00:22:27 PST 2025
Author: Kazu Hirata
Date: 2025-01-21T16:22:23+08:00
New Revision: 73beb153c1de9b5fab4086b89ac34c6c49a74fdc
URL: https://github.com/llvm/llvm-project/commit/73beb153c1de9b5fab4086b89ac34c6c49a74fdc
DIFF: https://github.com/llvm/llvm-project/commit/73beb153c1de9b5fab4086b89ac34c6c49a74fdc.diff
LOG: [MC] Avoid repeated hash lookups (NFC) (#123698)
Added:
Modified:
llvm/lib/MC/WasmObjectWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 8ddbe929e68b94..c5a95cb3da5433 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -746,10 +746,11 @@ static void addData(SmallVectorImpl<char> &DataBytes,
uint32_t
WasmObjectWriter::getRelocationIndexValue(const WasmRelocationEntry &RelEntry) {
if (RelEntry.Type == wasm::R_WASM_TYPE_INDEX_LEB) {
- if (!TypeIndices.count(RelEntry.Symbol))
+ auto It = TypeIndices.find(RelEntry.Symbol);
+ if (It == TypeIndices.end())
report_fatal_error("symbol not found in type index space: " +
RelEntry.Symbol->getName());
- return TypeIndices[RelEntry.Symbol];
+ return It->second;
}
return RelEntry.Symbol->getIndex();
More information about the llvm-commits
mailing list