Function consistenttime::ct_select_usize
[−]
[src]
pub extern fn ct_select_usize(flag: bool, x: usize, y: usize) -> usize
Optional swapping.
Allow to set a varible optionally at the same speed without branching, or changing speed.
Returns X if flag == True.
Returns Y if flag == False.
At compile time this becomes a CMOV. This is a brach. The branch misprediction cost is ~20cycles. And if this is incurred does not depend on the input, but the random state of our machine + quantum winds.
This should provide a consistent guarantee of speed.