Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions llvm/include/llvm/ADT/DenseMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class DenseMapBase : public DebugEpochBase {
return;
}
derived().deallocateBuckets();
derived().init(NewNumBuckets);
initWithExactBucketCount(NewNumBuckets);
}

/// Return true if the specified key is in the map, false otherwise.
Expand Down Expand Up @@ -750,9 +750,9 @@ class DenseMap : public DenseMapBase<DenseMap<KeyT, ValueT, KeyInfoT, BucketT>,
public:
/// Create a DenseMap with an optional \p NumElementsToReserve to guarantee
/// that this number of elements can be inserted in the map without grow().
explicit DenseMap(unsigned NumElementsToReserve = 0) {
init(NumElementsToReserve);
}
explicit DenseMap(unsigned NumElementsToReserve = 0)
: DenseMap(BaseT::getMinBucketToReserveForEntries(NumElementsToReserve),
typename BaseT::ExactBucketCount{}) {}

DenseMap(const DenseMap &other) : DenseMap() { this->copyFrom(other); }

Expand Down Expand Up @@ -784,7 +784,7 @@ class DenseMap : public DenseMapBase<DenseMap<KeyT, ValueT, KeyInfoT, BucketT>,
DenseMap &operator=(DenseMap &&other) {
this->destroyAll();
deallocateBuckets();
init(0);
this->initWithExactBucketCount(0);
this->swap(other);
return *this;
}
Expand Down Expand Up @@ -825,11 +825,6 @@ class DenseMap : public DenseMapBase<DenseMap<KeyT, ValueT, KeyInfoT, BucketT>,
return true;
}

void init(unsigned InitNumEntries) {
auto InitBuckets = BaseT::getMinBucketToReserveForEntries(InitNumEntries);
this->initWithExactBucketCount(InitBuckets);
}

// Put the zombie instance in a known good state after a move.
void kill() {
deallocateBuckets();
Expand Down Expand Up @@ -898,9 +893,10 @@ class SmallDenseMap
}

public:
explicit SmallDenseMap(unsigned NumElementsToReserve = 0) {
init(NumElementsToReserve);
}
explicit SmallDenseMap(unsigned NumElementsToReserve = 0)
: SmallDenseMap(
BaseT::getMinBucketToReserveForEntries(NumElementsToReserve),
typename BaseT::ExactBucketCount{}) {}

SmallDenseMap(const SmallDenseMap &other) : SmallDenseMap() {
this->copyFrom(other);
Expand Down Expand Up @@ -935,7 +931,7 @@ class SmallDenseMap
SmallDenseMap &operator=(SmallDenseMap &&other) {
this->destroyAll();
deallocateBuckets();
init(0);
this->initWithExactBucketCount(0);
this->swap(other);
return *this;
}
Expand Down Expand Up @@ -1091,11 +1087,6 @@ class SmallDenseMap
return true;
}

void init(unsigned InitNumEntries) {
auto InitBuckets = BaseT::getMinBucketToReserveForEntries(InitNumEntries);
this->initWithExactBucketCount(InitBuckets);
}

// Put the zombie instance in a known good state after a move.
void kill() {
deallocateBuckets();
Expand Down
Loading