Skip to content

Commit 3f1be86

Browse files
[Object] Avoid repeated hash lookups (NFC) (#123448)
1 parent fa9fb2a commit 3f1be86

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/Object/GOFFObjectFile.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ const uint8_t *GOFFObjectFile::getSymbolEsdRecord(DataRefImpl Symb) const {
190190
}
191191

192192
Expected<StringRef> GOFFObjectFile::getSymbolName(DataRefImpl Symb) const {
193-
if (EsdNamesCache.count(Symb.d.a)) {
194-
auto &StrPtr = EsdNamesCache[Symb.d.a];
193+
if (auto It = EsdNamesCache.find(Symb.d.a); It != EsdNamesCache.end()) {
194+
auto &StrPtr = It->second;
195195
return StringRef(StrPtr.second.get(), StrPtr.first);
196196
}
197197

@@ -459,8 +459,8 @@ uint64_t GOFFObjectFile::getSectionSize(DataRefImpl Sec) const {
459459
// a contiguous sequence of bytes.
460460
Expected<ArrayRef<uint8_t>>
461461
GOFFObjectFile::getSectionContents(DataRefImpl Sec) const {
462-
if (SectionDataCache.count(Sec.d.a)) {
463-
auto &Buf = SectionDataCache[Sec.d.a];
462+
if (auto It = SectionDataCache.find(Sec.d.a); It != SectionDataCache.end()) {
463+
auto &Buf = It->second;
464464
return ArrayRef<uint8_t>(Buf);
465465
}
466466
uint64_t SectionSize = getSectionSize(Sec);

0 commit comments

Comments
 (0)