[PATCH] D80708: Improve SmallPtrSetImpl::count implementation

serge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 31 22:54:53 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG11efb0837c89: Improve SmallPtrSetImpl::count implementation (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80708

Files:
  llvm/include/llvm/ADT/SmallPtrSet.h


Index: llvm/include/llvm/ADT/SmallPtrSet.h
===================================================================
--- llvm/include/llvm/ADT/SmallPtrSet.h
+++ llvm/include/llvm/ADT/SmallPtrSet.h
@@ -372,7 +372,9 @@
     return erase_imp(PtrTraits::getAsVoidPointer(Ptr));
   }
   /// count - Return 1 if the specified pointer is in the set, 0 otherwise.
-  size_type count(ConstPtrType Ptr) const { return find(Ptr) != end() ? 1 : 0; }
+  size_type count(ConstPtrType Ptr) const {
+    return find_imp(ConstPtrTraits::getAsVoidPointer(Ptr)) != EndPointer();
+  }
   iterator find(ConstPtrType Ptr) const {
     return makeIterator(find_imp(ConstPtrTraits::getAsVoidPointer(Ptr)));
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80708.267544.patch
Type: text/x-patch
Size: 682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200601/95e29e1d/attachment-0001.bin>


More information about the llvm-commits mailing list