@@ -348,11 +348,11 @@ class DenseMapBase : public DebugEpochBase {
348
348
}
349
349
350
350
ValueT &operator [](const KeyT &Key) {
351
- return try_emplace_impl (Key).first ->second ;
351
+ return lookupOrInsertIntoBucket (Key).first ->second ;
352
352
}
353
353
354
354
ValueT &operator [](KeyT &&Key) {
355
- return try_emplace_impl (std::move (Key)).first ->second ;
355
+ return lookupOrInsertIntoBucket (std::move (Key)).first ->second ;
356
356
}
357
357
358
358
// / isPointerIntoBucketsArray - Return true if the specified pointer points
@@ -477,16 +477,24 @@ class DenseMapBase : public DebugEpochBase {
477
477
478
478
private:
479
479
template <typename KeyArgT, typename ... Ts>
480
- std::pair<iterator, bool > try_emplace_impl (KeyArgT &&Key, Ts &&...Args) {
480
+ std::pair<BucketT *, bool > lookupOrInsertIntoBucket (KeyArgT &&Key,
481
+ Ts &&...Args) {
481
482
BucketT *TheBucket = nullptr ;
482
483
if (LookupBucketFor (Key, TheBucket))
483
- return {makeInsertIterator ( TheBucket) , false }; // Already in the map.
484
+ return {TheBucket, false }; // Already in the map.
484
485
485
486
// Otherwise, insert the new element.
486
487
TheBucket = findBucketForInsertion (Key, TheBucket);
487
488
TheBucket->getFirst () = std::forward<KeyArgT>(Key);
488
489
::new (&TheBucket->getSecond ()) ValueT (std::forward<Ts>(Args)...);
489
- return {makeInsertIterator (TheBucket), true };
490
+ return {TheBucket, true };
491
+ }
492
+
493
+ template <typename KeyArgT, typename ... Ts>
494
+ std::pair<iterator, bool > try_emplace_impl (KeyArgT &&Key, Ts &&...Args) {
495
+ auto [Bucket, Inserted] = lookupOrInsertIntoBucket (
496
+ std::forward<KeyArgT>(Key), std::forward<Ts>(Args)...);
497
+ return {makeInsertIterator (Bucket), Inserted};
490
498
}
491
499
492
500
iterator makeIterator (BucketT *P, BucketT *E, DebugEpochBase &Epoch,
0 commit comments