[llvm] c014db4 - [ADT] Remove the const variant of LookupBucketFor in DenseMap (#107608)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 10:55:41 PDT 2024
Author: Kazu Hirata
Date: 2024-09-06T10:55:38-07:00
New Revision: c014db47ca298ad7a0f52a57c3bfc2a9914371b2
URL: https://github.com/llvm/llvm-project/commit/c014db47ca298ad7a0f52a57c3bfc2a9914371b2
DIFF: https://github.com/llvm/llvm-project/commit/c014db47ca298ad7a0f52a57c3bfc2a9914371b2.diff
LOG: [ADT] Remove the const variant of LookupBucketFor in DenseMap (#107608)
DenseMap has const and non-const variants of LookupBucketFor to find a
bucket for insertion purposes. Now that queries (e.g. find, contains,
and erase) have been migrated to use doFind instead of
LookupBucketFor, nobody uses the const variant of LookupBucketFor.
This patch removes the const variant.
As far as the logistics go, the non-const variant calls the const
variant with a couple of const_cast, so this patch repurposes the
const variant as the non-const one while removing the original
non-const variant.
Added:
Modified:
llvm/include/llvm/ADT/DenseMap.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 745288ff047f4a..00290c9dd0a585 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -678,10 +678,9 @@ class DenseMapBase : public DebugEpochBase {
/// FoundBucket. If the bucket contains the key and a value, this returns
/// true, otherwise it returns a bucket with an empty marker or tombstone and
/// returns false.
- template<typename LookupKeyT>
- bool LookupBucketFor(const LookupKeyT &Val,
- const BucketT *&FoundBucket) const {
- const BucketT *BucketsPtr = getBuckets();
+ template <typename LookupKeyT>
+ bool LookupBucketFor(const LookupKeyT &Val, BucketT *&FoundBucket) {
+ BucketT *BucketsPtr = getBuckets();
const unsigned NumBuckets = getNumBuckets();
if (NumBuckets == 0) {
@@ -690,7 +689,7 @@ class DenseMapBase : public DebugEpochBase {
}
// FoundTombstone - Keep track of whether we find a tombstone while probing.
- const BucketT *FoundTombstone = nullptr;
+ BucketT *FoundTombstone = nullptr;
const KeyT EmptyKey = getEmptyKey();
const KeyT TombstoneKey = getTombstoneKey();
assert(!KeyInfoT::isEqual(Val, EmptyKey) &&
@@ -700,7 +699,7 @@ class DenseMapBase : public DebugEpochBase {
unsigned BucketNo = getHashValue(Val) & (NumBuckets-1);
unsigned ProbeAmt = 1;
while (true) {
- const BucketT *ThisBucket = BucketsPtr + BucketNo;
+ BucketT *ThisBucket = BucketsPtr + BucketNo;
// Found Val's bucket? If so, return it.
if (LLVM_LIKELY(KeyInfoT::isEqual(Val, ThisBucket->getFirst()))) {
FoundBucket = ThisBucket;
@@ -729,15 +728,6 @@ class DenseMapBase : public DebugEpochBase {
}
}
- template <typename LookupKeyT>
- bool LookupBucketFor(const LookupKeyT &Val, BucketT *&FoundBucket) {
- const BucketT *ConstFoundBucket;
- bool Result = const_cast<const DenseMapBase *>(this)
- ->LookupBucketFor(Val, ConstFoundBucket);
- FoundBucket = const_cast<BucketT *>(ConstFoundBucket);
- return Result;
- }
-
public:
/// Return the approximate size (in bytes) of the actual map.
/// This is just the raw memory used by DenseMap.
More information about the llvm-commits
mailing list