| 59 | } |
| 60 | |
| 61 | void insert(UInt key) { |
| 62 | // Rebuild at 90% full with allocation of +50% of space means minimum |
| 63 | // load factor is 60% and average is 75%. |
| 64 | // Although this computation is on the hot path, compiler elides division |
| 65 | // and benchmark shows that there is no difference performance penalty |
| 66 | // compared to storing this number precomputed. |
| 67 | if (size_ >= rehashSize()) { |
| 68 | DropSet dst{probeLimit_, rehashCapacity()}; |
| 69 | for (uint32_t i = 0; i < capacity_; i++) { |
| 70 | if (table_[i] != kEmptyKey) { |
| 71 | dst.insertNoResize(table_[i]); |
| 72 | } |
| 73 | } |
| 74 | *this = std::move(dst); |
| 75 | } |
| 76 | insertNoResize(key); |
| 77 | } |
| 78 | |
| 79 | bool lookup(UInt key) const { |
| 80 | uint32_t lookupProbeDistance{0}; |