[llvm-branch-commits] [llvm] [ADT] Use range-based helper functions in SmallSet (PR #108585)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Sep 18 01:38:55 PDT 2024


================
@@ -234,19 +225,12 @@ class SmallSet {
   /// Check if the SmallSet contains the given element.
   bool contains(const T &V) const {
     if (isSmall())
-      return vfind(V) != Vector.end();
-    return Set.find(V) != Set.end();
+      return llvm::is_contained(Vector, V);
+    return llvm::is_contained(Set, V);
----------------
nikic wrote:

If you want to have an abstraction over contains() and find() != end(), I'd suggest adding another helper, which does not also include the linear scan case. Though I don't think this is really worthwhile, as the existing find() != end() code works fine.

https://github.com/llvm/llvm-project/pull/108585


More information about the llvm-branch-commits mailing list