Commit fdbef6a
committed
[ADT] Remove DenseMap::init (NFC)
This patch removes DenseMap::init and SmallDenseMap::init by inlining
them into their call sites and simplifying them.
init() is defined as:
void init(unsigned InitNumEntries) {
auto InitBuckets = BaseT::getMinBucketToReserveForEntries(InitNumEntries);
this->initWithExactBucketCount(InitBuckets);
}
- Constuctors: Now that we have constructors that allocate the exact
number of buckets (as opposed to the number of key/value pairs),
init() does too much. Once we convert the number of key/value pairs
to the number of buckets, we can call the constructors that take the
exact number of buckets.
- init(0) in the move assignment operators simplifies down to:
initWithExactBucketCount(0)
- shrink_and_clear() computes the number of buckets to have after the
clear operation. As such, we should call initWithExactBucketCount,
not init. Otherwise, we would end up adding "load factor padding"
on top of NewNumBuckets:
NextPowerOf2(NewNumBuckets * 4 / 3 + 1)
All in all, init() doesn't bring any value in the current setup.
This patch is part of the effort outlined in #168255.1 parent 0602678 commit fdbef6a
1 file changed
+10
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
750 | 750 | | |
751 | 751 | | |
752 | 752 | | |
753 | | - | |
754 | | - | |
755 | | - | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
756 | 756 | | |
757 | 757 | | |
758 | 758 | | |
| |||
784 | 784 | | |
785 | 785 | | |
786 | 786 | | |
787 | | - | |
| 787 | + | |
788 | 788 | | |
789 | 789 | | |
790 | 790 | | |
| |||
825 | 825 | | |
826 | 826 | | |
827 | 827 | | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | 828 | | |
834 | 829 | | |
835 | 830 | | |
| |||
898 | 893 | | |
899 | 894 | | |
900 | 895 | | |
901 | | - | |
902 | | - | |
903 | | - | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
904 | 900 | | |
905 | 901 | | |
906 | 902 | | |
| |||
935 | 931 | | |
936 | 932 | | |
937 | 933 | | |
938 | | - | |
| 934 | + | |
939 | 935 | | |
940 | 936 | | |
941 | 937 | | |
| |||
1091 | 1087 | | |
1092 | 1088 | | |
1093 | 1089 | | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | 1090 | | |
1100 | 1091 | | |
1101 | 1092 | | |
| |||
0 commit comments