Hashmap branchless probing code


#1

I am confused by the following code.

If I understand correctly, it relies on the fact that the capacity is a power of 2.
x & capacity-1 is then a convoluted way to express x < capacity.

What I don’t get, is how is this an improvement, why is this an improvement over using < ?
Both compile to a conditional move instruction.

https://godbolt.org/g/AKWM6L


#2

Actually I understood that one… self.idx is not wrapping. It can take values greater than the capacity. The code is really trying to check self.idx % capacity == 0.