[PATCH] D113073: [lld-macho] Cache library paths from findLibrary

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 2 19:36:26 PDT 2021


int3 added inline comments.


================
Comment at: lld/MachO/Driver.cpp:83
 
+static DenseMap<CachedHashStringRef, StringRef> resolvedLibraries;
 static Optional<StringRef> findLibrary(StringRef name) {
----------------
ditto about `cleanupCallback` (as mentioned in D113063)


================
Comment at: lld/MachO/Driver.cpp:85-106
+  CachedHashStringRef key(name);
+  auto entry = resolvedLibraries.find(key);
+  if (entry != resolvedLibraries.end())
+    return entry->second;
+
   if (config->searchDylibsFirst) {
     if (Optional<StringRef> path = findPathCombination(
----------------
keith wrote:
> int3 wrote:
> > keith wrote:
> > > oontvoo wrote:
> > > > 
> > > Ah great idea, thanks!
> > what value does the lambda add here?
> IMO the reduced duplication is a big benefit
oh right. I saw it only being invoked once and got confused, but I see that it's actually factoring out the assignment. I should read more carefully before commenting 😅


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113073/new/

https://reviews.llvm.org/D113073



More information about the llvm-commits mailing list