Skip to content

Commit 7732d8e

Browse files
[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.
1 parent 6c143a8 commit 7732d8e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

llvm/include/llvm/ADT/DenseMap.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ class DenseMapBase : public DebugEpochBase {
354354
incrementNumTombstones();
355355
}
356356

357-
value_type& FindAndConstruct(const KeyT &Key) {
357+
LLVM_DEPRECATED("Use [Key] instead", "[Key]")
358+
value_type &FindAndConstruct(const KeyT &Key) {
358359
BucketT *TheBucket;
359360
if (LookupBucketFor(Key, TheBucket))
360361
return *TheBucket;
@@ -363,10 +364,15 @@ class DenseMapBase : public DebugEpochBase {
363364
}
364365

365366
ValueT &operator[](const KeyT &Key) {
366-
return FindAndConstruct(Key).second;
367+
BucketT *TheBucket;
368+
if (LookupBucketFor(Key, TheBucket))
369+
return TheBucket->second;
370+
371+
return InsertIntoBucket(TheBucket, Key)->second;
367372
}
368373

369-
value_type& FindAndConstruct(KeyT &&Key) {
374+
LLVM_DEPRECATED("Use [Key] instead", "[Key]")
375+
value_type &FindAndConstruct(KeyT &&Key) {
370376
BucketT *TheBucket;
371377
if (LookupBucketFor(Key, TheBucket))
372378
return *TheBucket;
@@ -375,7 +381,11 @@ class DenseMapBase : public DebugEpochBase {
375381
}
376382

377383
ValueT &operator[](KeyT &&Key) {
378-
return FindAndConstruct(std::move(Key)).second;
384+
BucketT *TheBucket;
385+
if (LookupBucketFor(Key, TheBucket))
386+
return TheBucket->second;
387+
388+
return InsertIntoBucket(TheBucket, std::move(Key))->second;
379389
}
380390

381391
/// isPointerIntoBucketsArray - Return true if the specified pointer points

0 commit comments

Comments
 (0)