I am confused by the following code.
https://github.com/rust-lang/rust/blob/b4e89728f450aba54efb9fa88e95a84acaae862b/src/libstd/collections/hash/table.rs#L309-L321
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.