Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions llvm/include/llvm/ADT/SmallPtrSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,18 +476,20 @@ template <typename PtrType> class SmallPtrSetImpl : public SmallPtrSetImplBase {
}

[[nodiscard]] iterator begin() const {
if (shouldReverseIterate())
if constexpr (shouldReverseIterate())
return makeIterator(EndPointer() - 1);
return makeIterator(CurArray);
else
return makeIterator(CurArray);
}
[[nodiscard]] iterator end() const { return makeIterator(EndPointer()); }

private:
/// Create an iterator that dereferences to same place as the given pointer.
iterator makeIterator(const void *const *P) const {
if (shouldReverseIterate())
if constexpr (shouldReverseIterate())
return iterator(P == EndPointer() ? CurArray : P + 1, CurArray, *this);
return iterator(P, EndPointer(), *this);
else
return iterator(P, EndPointer(), *this);
}
};

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Support/StringMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name,
// Hash table unallocated so far?
if (NumBuckets == 0)
init(16);
if (shouldReverseIterate())
if constexpr (shouldReverseIterate())
FullHashValue = ~FullHashValue;
unsigned BucketNo = FullHashValue & (NumBuckets - 1);
unsigned *HashTable = getHashTable(TheTable, NumBuckets);
Expand Down Expand Up @@ -142,7 +142,7 @@ int StringMapImpl::FindKey(StringRef Key, uint32_t FullHashValue) const {
#ifdef EXPENSIVE_CHECKS
assert(FullHashValue == hash(Key));
#endif
if (shouldReverseIterate())
if constexpr (shouldReverseIterate())
FullHashValue = ~FullHashValue;
unsigned BucketNo = FullHashValue & (NumBuckets - 1);
unsigned *HashTable = getHashTable(TheTable, NumBuckets);
Expand Down