projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix an off by 1 bug that prevented SmallPtrSet from using all of its 'small' capacity...
[oota-llvm.git]
/
lib
/
Support
/
SmallPtrSet.cpp
diff --git
a/lib/Support/SmallPtrSet.cpp
b/lib/Support/SmallPtrSet.cpp
index 844e41696f9293add19530459b4f1ebe26d38920..621b90fa75572bfe4c534a90a1238cac24a3a66f 100644
(file)
--- 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.
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;
}
SmallArray[NumElements++] = Ptr;
return true;
}
@@
-103,7
+103,7
@@
const void * const *SmallPtrSetImplBase::FindBucketFor(const void *Ptr) const {
unsigned ArraySize = CurArraySize;
unsigned ProbeAmt = 1;
const void *const *Array = CurArray;
unsigned ArraySize = CurArraySize;
unsigned ProbeAmt = 1;
const void *const *Array = CurArray;
- const void *const *Tombstone =
0
;
+ const void *const *Tombstone =
nullptr
;
while (1) {
// Found Ptr's bucket?
if (Array[Bucket] == Ptr)
while (1) {
// Found Ptr's bucket?
if (Array[Bucket] == Ptr)
@@
-200,13
+200,12
@@
SmallPtrSetImplBase::SmallPtrSetImplBase(const void **SmallStorage,
if (that.isSmall()) {
CurArray = SmallArray;
memcpy(CurArray, that.CurArray, sizeof(void *) * CurArraySize);
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);
// Make the "that" object small and empty.
that.CurArraySize = SmallSize;
assert(that.CurArray == that.SmallArray);