[PATCH] D16619: SmallPtrSet: Put the part of insert() on small sets into the header
Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 26 20:24:32 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL258908: SmallPtrSet: Inline the part of insert_imp in the small case (authored by matze).
Changed prior to commit:
http://reviews.llvm.org/D16619?vs=46093&id=46097#toc
Repository:
rL LLVM
http://reviews.llvm.org/D16619
Files:
llvm/trunk/include/llvm/ADT/SmallPtrSet.h
llvm/trunk/lib/Support/SmallPtrSet.cpp
Index: llvm/trunk/lib/Support/SmallPtrSet.cpp
===================================================================
--- llvm/trunk/lib/Support/SmallPtrSet.cpp
+++ llvm/trunk/lib/Support/SmallPtrSet.cpp
@@ -35,22 +35,7 @@
}
std::pair<const void *const *, bool>
-SmallPtrSetImplBase::insert_imp(const void *Ptr) {
- if (isSmall()) {
- // Check to see if it is already in the set.
- for (const void **APtr = SmallArray, **E = SmallArray+NumElements;
- APtr != E; ++APtr)
- if (*APtr == Ptr)
- return std::make_pair(APtr, false);
-
- // Nope, there isn't. If we stay small, just 'pushback' now.
- if (NumElements < CurArraySize) {
- SmallArray[NumElements++] = Ptr;
- return std::make_pair(SmallArray + (NumElements - 1), true);
- }
- // Otherwise, hit the big set case, which will call grow.
- }
-
+SmallPtrSetImplBase::insert_imp_big(const void *Ptr) {
if (LLVM_UNLIKELY(NumElements * 4 >= CurArraySize * 3)) {
// If more than 3/4 of the array is full, grow.
Grow(CurArraySize < 64 ? 128 : CurArraySize*2);
Index: llvm/trunk/include/llvm/ADT/SmallPtrSet.h
===================================================================
--- llvm/trunk/include/llvm/ADT/SmallPtrSet.h
+++ llvm/trunk/include/llvm/ADT/SmallPtrSet.h
@@ -102,7 +102,23 @@
/// insert_imp - This returns true if the pointer was new to the set, false if
/// it was already in the set. This is hidden from the client so that the
/// derived class can check that the right type of pointer is passed in.
- std::pair<const void *const *, bool> insert_imp(const void *Ptr);
+ std::pair<const void *const *, bool> insert_imp(const void *Ptr) {
+ if (isSmall()) {
+ // Check to see if it is already in the set.
+ for (const void **APtr = SmallArray, **E = SmallArray+NumElements;
+ APtr != E; ++APtr)
+ if (*APtr == Ptr)
+ return std::make_pair(APtr, false);
+
+ // Nope, there isn't. If we stay small, just 'pushback' now.
+ if (NumElements < CurArraySize) {
+ SmallArray[NumElements++] = Ptr;
+ return std::make_pair(SmallArray + (NumElements - 1), true);
+ }
+ // Otherwise, hit the big set case, which will call grow.
+ }
+ return insert_imp_big(Ptr);
+ }
/// erase_imp - If the set contains the specified pointer, remove it and
/// return true, otherwise return false. This is hidden from the client so
@@ -127,6 +143,8 @@
private:
bool isSmall() const { return CurArray == SmallArray; }
+ std::pair<const void *const *, bool> insert_imp_big(const void *Ptr);
+
const void * const *FindBucketFor(const void *Ptr) const;
void shrink_and_clear();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16619.46097.patch
Type: text/x-patch
Size: 2686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160127/3a891a9f/attachment.bin>
More information about the llvm-commits
mailing list