#performance
Wiki
›
Algorithms
›
01. Searching and Sorting
›
12. Specialized Search and Sorted-Order Procedures
›
Branchless Binary Search
Branchless Binary Search Branchless binary search is a binary search variant designed to reduce branch mispredictions. A normal binary search repeatedly branches on whether the middle value is less than the target. On modern CPUs, this branch can be hard to predict because the search direction depends on the data. A branchless version keeps the same comparison logic but updates the search position using conditional moves, masks, or arithmetic expressions....