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

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 18 23:19:25 PDT 2024


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

None

>From 098d6250bb7cfce73d59cdee54358f2a1d2e595b Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 17 Sep 2024 00:30:38 -0700
Subject: [PATCH] [GSYM] Avoid repeated hash lookups (NFC)

---
 llvm/lib/DebugInfo/GSYM/GsymCreator.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

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;
 }
 



More information about the llvm-commits mailing list