Skip to content

Commit 85ab209

Browse files
[ADT] Inline InsertIntoBucket and InsertIntoBucketWithLookup into their callers (NFC) (#155550)
InsertIntoBucket and InsertIntoBucketWithLookup each has exactly one caller. This patch inlines them into their respective sole callers, reducing the line count. While we are at it, this patch renames InsertIntoBucketImpl to findBucketForInsertion to better reflect its purpose now that InsertIntoBucket is being removed.
1 parent 7f11850 commit 85ab209

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

llvm/include/llvm/ADT/DenseMap.h

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,9 @@ class DenseMapBase : public DebugEpochBase {
279279
return {makeInsertIterator(TheBucket), false}; // Already in map.
280280

281281
// Otherwise, insert the new element.
282-
TheBucket = InsertIntoBucketWithLookup(TheBucket, std::move(KV.first),
283-
std::move(KV.second), Val);
282+
TheBucket = findBucketForInsertion(Val, TheBucket);
283+
TheBucket->getFirst() = std::move(KV.first);
284+
::new (&TheBucket->getSecond()) ValueT(std::move(KV.second));
284285
return {makeInsertIterator(TheBucket), true};
285286
}
286287

@@ -482,8 +483,9 @@ class DenseMapBase : public DebugEpochBase {
482483
return {makeInsertIterator(TheBucket), false}; // Already in the map.
483484

484485
// Otherwise, insert the new element.
485-
TheBucket = InsertIntoBucket(TheBucket, std::forward<KeyArgT>(Key),
486-
std::forward<Ts>(Args)...);
486+
TheBucket = findBucketForInsertion(Key, TheBucket);
487+
TheBucket->getFirst() = std::forward<KeyArgT>(Key);
488+
::new (&TheBucket->getSecond()) ValueT(std::forward<Ts>(Args)...);
487489
return {makeInsertIterator(TheBucket), true};
488490
}
489491

@@ -561,28 +563,9 @@ class DenseMapBase : public DebugEpochBase {
561563

562564
void shrink_and_clear() { static_cast<DerivedT *>(this)->shrink_and_clear(); }
563565

564-
template <typename KeyArg, typename... ValueArgs>
565-
BucketT *InsertIntoBucket(BucketT *TheBucket, KeyArg &&Key,
566-
ValueArgs &&...Values) {
567-
TheBucket = InsertIntoBucketImpl(Key, TheBucket);
568-
569-
TheBucket->getFirst() = std::forward<KeyArg>(Key);
570-
::new (&TheBucket->getSecond()) ValueT(std::forward<ValueArgs>(Values)...);
571-
return TheBucket;
572-
}
573-
574-
template <typename LookupKeyT>
575-
BucketT *InsertIntoBucketWithLookup(BucketT *TheBucket, KeyT &&Key,
576-
ValueT &&Value, LookupKeyT &Lookup) {
577-
TheBucket = InsertIntoBucketImpl(Lookup, TheBucket);
578-
579-
TheBucket->getFirst() = std::move(Key);
580-
::new (&TheBucket->getSecond()) ValueT(std::move(Value));
581-
return TheBucket;
582-
}
583-
584566
template <typename LookupKeyT>
585-
BucketT *InsertIntoBucketImpl(const LookupKeyT &Lookup, BucketT *TheBucket) {
567+
BucketT *findBucketForInsertion(const LookupKeyT &Lookup,
568+
BucketT *TheBucket) {
586569
incrementEpoch();
587570

588571
// If the load of the hash table is more than 3/4, or if fewer than 1/8 of

0 commit comments

Comments
 (0)