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>;



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>;

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to