[PATCH] D118945: [lld-macho] Minor clean up: use .find() to check for key existence rather than [], which would create a new entry.

Vy Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 3 14:05:13 PST 2022


oontvoo created this revision.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
oontvoo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118945

Files:
  lld/MachO/Driver.cpp


Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -267,8 +267,9 @@
     // We don't take a reference to cachedFile here because the
     // loadArchiveMember() call below may recursively call addFile() and
     // invalidate this reference.
-    if (ArchiveFile *cachedFile = loadedArchives[path])
-      return cachedFile;
+    auto entry = loadedArchives.find(path);
+    if (entry != loadedArchives.end())
+      return entry->second;
 
     std::unique_ptr<object::Archive> archive = CHECK(
         object::Archive::create(mbref), path + ": failed to parse archive");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118945.405782.patch
Type: text/x-patch
Size: 672 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220203/c536c9f1/attachment.bin>


More information about the llvm-commits mailing list