mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-02 04:39:35 +00:00
make smallptrset more const and type correct, which caught a few
minor bugs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43782 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0d97426b7b
commit
373a733be0
@ -91,21 +91,19 @@ public:
|
|||||||
NumTombstones = 0;
|
NumTombstones = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// insert - This returns true if the pointer was new to the set, false if it
|
protected:
|
||||||
/// was already in the set.
|
/// insert_imp - This returns true if the pointer was new to the set, false if
|
||||||
bool insert(const void * Ptr);
|
/// 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.
|
||||||
|
bool insert_imp(const void * Ptr);
|
||||||
|
|
||||||
template <typename IterT>
|
/// erase_imp - If the set contains the specified pointer, remove it and
|
||||||
void insert(IterT I, IterT E) {
|
/// return true, otherwise return false. This is hidden from the client so
|
||||||
for (; I != E; ++I)
|
/// that the derived class can check that the right type of pointer is passed
|
||||||
insert((void*)*I);
|
/// in.
|
||||||
}
|
bool erase_imp(const void * Ptr);
|
||||||
|
|
||||||
/// erase - If the set contains the specified pointer, remove it and return
|
bool count_imp(const void * Ptr) const {
|
||||||
/// true, otherwise return false.
|
|
||||||
bool erase(const void * Ptr);
|
|
||||||
|
|
||||||
bool count(const void * Ptr) const {
|
|
||||||
if (isSmall()) {
|
if (isSmall()) {
|
||||||
// Linear search for the item.
|
// Linear search for the item.
|
||||||
for (const void *const *APtr = SmallArray,
|
for (const void *const *APtr = SmallArray,
|
||||||
@ -232,6 +230,23 @@ public:
|
|||||||
insert(I, E);
|
insert(I, E);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// insert - This returns true if the pointer was new to the set, false if it
|
||||||
|
/// was already in the set.
|
||||||
|
bool insert(PtrType Ptr) { return insert_imp(Ptr); }
|
||||||
|
|
||||||
|
/// erase - If the set contains the specified pointer, remove it and return
|
||||||
|
/// true, otherwise return false.
|
||||||
|
bool erase(PtrType Ptr) { return erase_imp(Ptr); }
|
||||||
|
|
||||||
|
/// count - Return true if the specified pointer is in the set.
|
||||||
|
bool count(PtrType Ptr) const { return count_imp(Ptr); }
|
||||||
|
|
||||||
|
template <typename IterT>
|
||||||
|
void insert(IterT I, IterT E) {
|
||||||
|
for (; I != E; ++I)
|
||||||
|
insert(*I);
|
||||||
|
}
|
||||||
|
|
||||||
typedef SmallPtrSetIterator<PtrType> iterator;
|
typedef SmallPtrSetIterator<PtrType> iterator;
|
||||||
typedef SmallPtrSetIterator<PtrType> const_iterator;
|
typedef SmallPtrSetIterator<PtrType> const_iterator;
|
||||||
inline iterator begin() const {
|
inline iterator begin() const {
|
||||||
|
@ -36,7 +36,7 @@ void SmallPtrSetImpl::shrink_and_clear() {
|
|||||||
CurArray[CurArraySize] = 0;
|
CurArray[CurArraySize] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SmallPtrSetImpl::insert(const void * Ptr) {
|
bool SmallPtrSetImpl::insert_imp(const void * Ptr) {
|
||||||
if (isSmall()) {
|
if (isSmall()) {
|
||||||
// Check to see if it is already in the set.
|
// Check to see if it is already in the set.
|
||||||
for (const void **APtr = SmallArray, **E = SmallArray+NumElements;
|
for (const void **APtr = SmallArray, **E = SmallArray+NumElements;
|
||||||
@ -69,7 +69,7 @@ bool SmallPtrSetImpl::insert(const void * Ptr) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SmallPtrSetImpl::erase(const void * Ptr) {
|
bool SmallPtrSetImpl::erase_imp(const void * Ptr) {
|
||||||
if (isSmall()) {
|
if (isSmall()) {
|
||||||
// Check to see if it is in the set.
|
// Check to see if it is in the set.
|
||||||
for (const void **APtr = SmallArray, **E = SmallArray+NumElements;
|
for (const void **APtr = SmallArray, **E = SmallArray+NumElements;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user