[llvm] [GSYM] Avoid repeated hash lookups (NFC) (PR #109241)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 18 23:20:00 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/109241.diff


1 Files Affected:

- (modified) llvm/lib/DebugInfo/GSYM/GsymCreator.cpp (+1-2) 


``````````diff
diff --git a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
index 0418e3258a16bf..3227fa5400fb5c 100644
--- a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
+++ b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
@@ -375,8 +375,7 @@ uint32_t GsymCreator::insertString(StringRef S, bool Copy) {
   // Save a mapping of string offsets to the cached string reference in case
   // we need to segment the GSYM file and copy string from one string table to
   // another.
-  if (StringOffsetMap.count(StrOff) == 0)
-    StringOffsetMap.insert(std::make_pair(StrOff, CHStr));
+  StringOffsetMap.try_emplace(StrOff, CHStr);
   return StrOff;
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/109241


More information about the llvm-commits mailing list