[PATCH] D127599: [clang] small speed improvement of Sema::AddArgumentDependentLookupCandidates

Kókai Péter via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 12 07:07:19 PDT 2022


Kokan created this revision.
Kokan added a reviewer: clang.
Herald added a project: All.
Kokan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[clang] Improve speed of Sema::AddArgumentDependentLookupCandidates

The Sema::AddArgumentDependentLookupCandidates compile the list of
overload candidates found via ADL.

Also it makes sure not to include candidates if already found via not
ADL. It achives that distinct list via looping over candidates and
removing them from the ADL candidates(Fns).

When there is no candidate found via ADL, there is no need to loop over
the candidate list as Fns is empty so there is nothing to remove from
that.

Disclaimer: I do not have compile time measurement, but not doing a loop

  should be faster.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127599

Files:
  clang/include/clang/Sema/Lookup.h
  clang/lib/Sema/SemaOverload.cpp


Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9389,6 +9389,9 @@
   // FIXME: Pass in the explicit template arguments?
   ArgumentDependentLookup(Name, Loc, Args, Fns);

+  if (Fns.empty())
+     return;
+
   // Erase all of the candidates we already knew about.
   for (OverloadCandidateSet::iterator Cand = CandidateSet.begin(),
                                    CandEnd = CandidateSet.end();
Index: clang/include/clang/Sema/Lookup.h
===================================================================
--- clang/include/clang/Sema/Lookup.h
+++ clang/include/clang/Sema/Lookup.h
@@ -814,6 +814,10 @@
     Decls.erase(cast<NamedDecl>(D->getCanonicalDecl()));
   }

+  bool empty(void) {
+    return Decls.empty();
+  }
+
   using iterator =
       llvm::mapped_iterator<decltype(Decls)::iterator, select_second>;



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127599.436223.patch
Type: text/x-patch
Size: 952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220612/cd8c29aa/attachment.bin>


More information about the cfe-commits mailing list