aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/WasmObjectWriter.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2025-01-21 00:22:23 -0800
committerGitHub <noreply@github.com>2025-01-21 16:22:23 +0800
commit73beb153c1de9b5fab4086b89ac34c6c49a74fdc (patch)
tree5aad3e563dec5f0fdf83c09f3aab93ef9f80cbe0 /llvm/lib/MC/WasmObjectWriter.cpp
parent26b87aad9e2d34d53df67522dc5aea5f7c54a458 (diff)
downloadllvm-73beb153c1de9b5fab4086b89ac34c6c49a74fdc.zip
llvm-73beb153c1de9b5fab4086b89ac34c6c49a74fdc.tar.gz
llvm-73beb153c1de9b5fab4086b89ac34c6c49a74fdc.tar.bz2
[MC] Avoid repeated hash lookups (NFC) (#123698)
Diffstat (limited to 'llvm/lib/MC/WasmObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/WasmObjectWriter.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 8ddbe92..c5a95cb 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();