| 318 | // in the table. |
| 319 | template <typename Copier> |
| 320 | void FreshInsert(Bucket* src, uint32 src_index, Copier copier) { |
| 321 | size_t h = hash_(src->key(src_index)); |
| 322 | const uint32 marker = Marker(h & 0xff); |
| 323 | size_t index = (h >> 8) & mask_; // Holds bucket num and index-in-bucket |
| 324 | uint32 num_probes = 1; // Needed for quadratic probing |
| 325 | while (true) { |
| 326 | uint32 bi = index & (kWidth - 1); |
| 327 | Bucket* b = &array_[index >> kBase]; |
| 328 | const uint32 x = b->marker[bi]; |
| 329 | if (x == 0) { |
| 330 | b->marker[bi] = marker; |
| 331 | not_empty_++; |
| 332 | copier(b, bi, src, src_index); |
| 333 | return; |
| 334 | } |
| 335 | index = NextIndex(index, num_probes); |
| 336 | num_probes++; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | inline size_t NextIndex(size_t i, uint32 num_probes) const { |
| 341 | // Quadratic probing. |