Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That particular branch is well-predicted for long arrays. You probably only gonna have a single misprediction for the complete binary search function, the performance consequence of that branch is negligible.

People (and compilers, too) don’t write branchless code just for the sake of it, they do because it helps with performance.



sometimes branchless code also stops timing side channel attacks, but it's not enough by itself




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: