[llvm] 7732d8e - [ADT] Deprecate DenseMap::FindAndConstruct (#107224)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 06:51:34 PDT 2024
Author: Kazu Hirata
Date: 2024-09-04T06:51:30-07:00
New Revision: 7732d8e51819416b9d28b1815bdf81d0e0642b04
URL: https://github.com/llvm/llvm-project/commit/7732d8e51819416b9d28b1815bdf81d0e0642b04
DIFF: https://github.com/llvm/llvm-project/commit/7732d8e51819416b9d28b1815bdf81d0e0642b04.diff
LOG: [ADT] Deprecate DenseMap::FindAndConstruct (#107224)
I've migrated all uses of FindAndConstruct to operator[] and
try_emplace. This patch inlines FindAndConstruct into operator[] and
deprecates FindAndConstruct.
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 e78700f9a9f3ac..745288ff047f4a 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -354,7 +354,8 @@ class DenseMapBase : public DebugEpochBase {
incrementNumTombstones();
}
- value_type& FindAndConstruct(const KeyT &Key) {
+ LLVM_DEPRECATED("Use [Key] instead", "[Key]")
+ value_type &FindAndConstruct(const KeyT &Key) {
BucketT *TheBucket;
if (LookupBucketFor(Key, TheBucket))
return *TheBucket;
@@ -363,10 +364,15 @@ class DenseMapBase : public DebugEpochBase {
}
ValueT &operator[](const KeyT &Key) {
- return FindAndConstruct(Key).second;
+ BucketT *TheBucket;
+ if (LookupBucketFor(Key, TheBucket))
+ return TheBucket->second;
+
+ return InsertIntoBucket(TheBucket, Key)->second;
}
- value_type& FindAndConstruct(KeyT &&Key) {
+ LLVM_DEPRECATED("Use [Key] instead", "[Key]")
+ value_type &FindAndConstruct(KeyT &&Key) {
BucketT *TheBucket;
if (LookupBucketFor(Key, TheBucket))
return *TheBucket;
@@ -375,7 +381,11 @@ class DenseMapBase : public DebugEpochBase {
}
ValueT &operator[](KeyT &&Key) {
- return FindAndConstruct(std::move(Key)).second;
+ BucketT *TheBucket;
+ if (LookupBucketFor(Key, TheBucket))
+ return TheBucket->second;
+
+ return InsertIntoBucket(TheBucket, std::move(Key))->second;
}
/// isPointerIntoBucketsArray - Return true if the specified pointer points
More information about the llvm-commits
mailing list