[llvm] 3f1be86 - [Object] Avoid repeated hash lookups (NFC) (#123448)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 18 09:45:01 PST 2025


Author: Kazu Hirata
Date: 2025-01-18T09:44:58-08:00
New Revision: 3f1be86a1acd5286bac16cae833481ee3f80dcbb

URL: https://github.com/llvm/llvm-project/commit/3f1be86a1acd5286bac16cae833481ee3f80dcbb
DIFF: https://github.com/llvm/llvm-project/commit/3f1be86a1acd5286bac16cae833481ee3f80dcbb.diff

LOG: [Object] Avoid repeated hash lookups (NFC) (#123448)

Added: 
    

Modified: 
    llvm/lib/Object/GOFFObjectFile.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Object/GOFFObjectFile.cpp b/llvm/lib/Object/GOFFObjectFile.cpp
index e3c4383d27aadb..db1e7e704f62e1 100644
--- a/llvm/lib/Object/GOFFObjectFile.cpp
+++ b/llvm/lib/Object/GOFFObjectFile.cpp
@@ -190,8 +190,8 @@ const uint8_t *GOFFObjectFile::getSymbolEsdRecord(DataRefImpl Symb) const {
 }
 
 Expected<StringRef> GOFFObjectFile::getSymbolName(DataRefImpl Symb) const {
-  if (EsdNamesCache.count(Symb.d.a)) {
-    auto &StrPtr = EsdNamesCache[Symb.d.a];
+  if (auto It = EsdNamesCache.find(Symb.d.a); It != EsdNamesCache.end()) {
+    auto &StrPtr = It->second;
     return StringRef(StrPtr.second.get(), StrPtr.first);
   }
 
@@ -459,8 +459,8 @@ uint64_t GOFFObjectFile::getSectionSize(DataRefImpl Sec) const {
 // a contiguous sequence of bytes.
 Expected<ArrayRef<uint8_t>>
 GOFFObjectFile::getSectionContents(DataRefImpl Sec) const {
-  if (SectionDataCache.count(Sec.d.a)) {
-    auto &Buf = SectionDataCache[Sec.d.a];
+  if (auto It = SectionDataCache.find(Sec.d.a); It != SectionDataCache.end()) {
+    auto &Buf = It->second;
     return ArrayRef<uint8_t>(Buf);
   }
   uint64_t SectionSize = getSectionSize(Sec);


        


More information about the llvm-commits mailing list