X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FSmallPtrSet.cpp;h=621b90fa75572bfe4c534a90a1238cac24a3a66f;hb=78832c6e7d33094c6ef9e99b07dac6f60c0a1207;hp=a80e095ec35a927a7c1a3adb81a71a9b771539be;hpb=34bc6b6e787f27b5c9e05c82de4c1b4ac9b117bc;p=oota-llvm.git diff --git a/lib/Support/SmallPtrSet.cpp b/lib/Support/SmallPtrSet.cpp index a80e095ec35..621b90fa755 100644 --- a/lib/Support/SmallPtrSet.cpp +++ b/lib/Support/SmallPtrSet.cpp @@ -43,7 +43,7 @@ bool SmallPtrSetImplBase::insert_imp(const void * Ptr) { return false; // Nope, there isn't. If we stay small, just 'pushback' now. - if (NumElements < CurArraySize-1) { + if (NumElements < CurArraySize) { SmallArray[NumElements++] = Ptr; return true; } @@ -200,13 +200,12 @@ SmallPtrSetImplBase::SmallPtrSetImplBase(const void **SmallStorage, if (that.isSmall()) { CurArray = SmallArray; memcpy(CurArray, that.CurArray, sizeof(void *) * CurArraySize); - return; + } else { + // Otherwise, we steal the large memory allocation and no copy is needed. + CurArray = that.CurArray; + that.CurArray = that.SmallArray; } - // Otherwise, we steal the large memory allocation and no copy is needed. - CurArray = that.CurArray; - that.CurArray = that.SmallArray; - // Make the "that" object small and empty. that.CurArraySize = SmallSize; assert(that.CurArray == that.SmallArray);