Resize to the given number of buckets.
| 1152 | |
| 1153 | // Resize to the given number of buckets. |
| 1154 | void Resize(size_t new_num_buckets) { |
| 1155 | GOOGLE_DCHECK_GE(new_num_buckets, kMinTableSize); |
| 1156 | void** const old_table = table_; |
| 1157 | const size_type old_table_size = num_buckets_; |
| 1158 | num_buckets_ = new_num_buckets; |
| 1159 | table_ = CreateEmptyTable(num_buckets_); |
| 1160 | const size_type start = index_of_first_non_null_; |
| 1161 | index_of_first_non_null_ = num_buckets_; |
| 1162 | for (size_type i = start; i < old_table_size; i++) { |
| 1163 | if (TableEntryIsNonEmptyList(old_table, i)) { |
| 1164 | TransferList(old_table, i); |
| 1165 | } else if (TableEntryIsTree(old_table, i)) { |
| 1166 | TransferTree(old_table, i++); |
| 1167 | } |
| 1168 | } |
| 1169 | Dealloc<void*>(old_table, old_table_size); |
| 1170 | } |
| 1171 | |
| 1172 | void TransferList(void* const* table, size_type index) { |
| 1173 | Node* node = static_cast<Node*>(table[index]); |
nothing calls this directly
no outgoing calls
no test coverage detected