diff --git a/llvm/tools/dsymutil/BinaryHolder.cpp b/llvm/tools/dsymutil/BinaryHolder.cpp index 5daaa6755b295..7588a33eb46b2 100644 --- a/llvm/tools/dsymutil/BinaryHolder.cpp +++ b/llvm/tools/dsymutil/BinaryHolder.cpp @@ -176,8 +176,8 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename, // Try the cache first. std::lock_guard Lock(MemberCacheMutex); - if (MemberCache.count(Key)) - return *MemberCache[Key]; + if (auto It = MemberCache.find(Key); It != MemberCache.end()) + return *It->second; // Create a new ObjectEntry, but don't add it to the cache yet. Loading of // the archive members might fail and we don't want to lock the whole archive @@ -228,8 +228,7 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename, if (OE->Objects.empty()) return errorCodeToError(errc::no_such_file_or_directory); - MemberCache[Key] = std::move(OE); - return *MemberCache[Key]; + return *(MemberCache[Key] = std::move(OE)); } Expected