[PATCH] D28183: [SmallPtrSet] Introduce a find primitive and rewrite count/erase in terms of it
Sanjoy Das via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 30 17:30:55 PST 2016
sanjoy added a comment.
Please also add some tests.
================
Comment at: include/llvm/ADT/SmallPtrSet.h:167
+ const void *const *P = find_imp(Ptr);
+ if (P != EndPointer()) {
+ const void ** Loc = const_cast<const void **>(P);
----------------
Early return here if `P == EndPointer()`?
================
Comment at: include/llvm/ADT/SmallPtrSet.h:169
+ const void ** Loc = const_cast<const void **>(P);
+ *Loc = getTombstoneMarker();
+ NumTombstones++;
----------------
I'd add an assert here that `*Loc` is `Ptr`.
================
Comment at: include/llvm/ADT/SmallPtrSet.h:389
size_type count(PtrType Ptr) const {
- return count_imp(PtrTraits::getAsVoidPointer(Ptr)) ? 1 : 0;
+ return find(Ptr) != endPtr() ? 1 : 0;
+ }
----------------
What is `endPtr`? Is this patch based on some other patch?
https://reviews.llvm.org/D28183
More information about the llvm-commits
mailing list