Commit 3c54972
authored
[ADT] Remove DenseMap::init (NFC) (#168322)
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 dcf8cd9 commit 3c54972
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 | | |
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
758 | | - | |
759 | | - | |
760 | | - | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
761 | 761 | | |
762 | 762 | | |
763 | 763 | | |
| |||
789 | 789 | | |
790 | 790 | | |
791 | 791 | | |
792 | | - | |
| 792 | + | |
793 | 793 | | |
794 | 794 | | |
795 | 795 | | |
| |||
830 | 830 | | |
831 | 831 | | |
832 | 832 | | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | 833 | | |
839 | 834 | | |
840 | 835 | | |
| |||
902 | 897 | | |
903 | 898 | | |
904 | 899 | | |
905 | | - | |
906 | | - | |
907 | | - | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
908 | 904 | | |
909 | 905 | | |
910 | 906 | | |
| |||
939 | 935 | | |
940 | 936 | | |
941 | 937 | | |
942 | | - | |
| 938 | + | |
943 | 939 | | |
944 | 940 | | |
945 | 941 | | |
| |||
1095 | 1091 | | |
1096 | 1092 | | |
1097 | 1093 | | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | 1094 | | |
1104 | 1095 | | |
1105 | 1096 | | |
| |||
0 commit comments