1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

Fix an off by 1 bug that prevented SmallPtrSet from using all of its 'small' capacity. Then fix the early return in the move constructor that prevented 'small' moves from clearing the NumElements in the moved from object. The directed test missed this because it was always testing large moves due to the off by 1 bug.

llvm-svn: 216044
This commit is contained in:
Craig Topper 2014-08-20 04:41:36 +00:00
parent 266b262fd1
commit baef4556f6

View File

@ -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);