[llvm] [MC] Avoid repeated hash lookups (NFC) (PR #123698)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 20 23:01:52 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-webassembly
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/123698.diff
1 Files Affected:
- (modified) llvm/lib/MC/WasmObjectWriter.cpp (+3-2)
``````````diff
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();
``````````
</details>
https://github.com/llvm/llvm-project/pull/123698
More information about the llvm-commits
mailing list