-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[ADT] Deprecate DenseMap::FindAndConstruct #107224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADT] Deprecate DenseMap::FindAndConstruct #107224
Conversation
I've migrated all uses of FindAndConstruct to operator[] and try_emplace. This patch inlines FindAndConstruct into operator[] and deprecates FindAndConstruct.
@llvm/pr-subscribers-llvm-adt Author: Kazu Hirata (kazutakahirata) ChangesI've migrated all uses of FindAndConstruct to operator[] and Full diff: https://github.com/llvm/llvm-project/pull/107224.diff 1 Files Affected:
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/30/builds/5438 Here is the relevant piece of the build log for the reference
|
I've migrated all uses of FindAndConstruct to operator[] and
try_emplace. This patch inlines FindAndConstruct into operator[] and
deprecates FindAndConstruct.