1. The article discusses a branchless binary search algorithm called "Shar's algorithm" that was originally proposed by Leonard E Shar in 1971 and later described in John L Bentley's book from 1982.
2. The algorithm uses powers of two to jump through the array being searched, and is faster than std::lower_bound in GCC, but may be slower for expensive comparison functions or when searching for strings.
3. The code for the algorithm is available on GitHub under the boost license, and the author has included a donation button for those who find open source work like this valuable.
The article discusses a binary search algorithm called "Shar's algorithm" that is branchless and faster than std::lower_bound in GCC. The author provides code for the algorithm and explains how it works, including its use of powers of two and its conditional move instruction. The article also compares the performance of branchless_lower_bound to std::lower_bound in both GCC and Clang, as well as for searching strings.
The author notes that the comparison function provided by the user can impact the performance of branchless_lower_bound, but overall it is worth using if the comparison function is not too expensive. The article also tracks down the source of Shar's algorithm to John L Bentley's book from 1982, which was inspired by Knuth's "Sorting and Searching".
Overall, the article provides a detailed analysis of Shar's algorithm and its performance compared to std::lower_bound. However, there are some potential biases in the article. For example, the author only tests the algorithm in GCC and Clang, so it is unclear how it performs in other compilers. Additionally, while the author acknowledges that std::lower_bound may be faster if the comparison function is expensive, they do not provide any evidence or examples to support this claim.
Furthermore, while the article does mention some limitations of Shar's algorithm (such as its use of powers of two leading to more comparisons), it does not explore any potential risks or downsides beyond performance. It also does not present any counterarguments or alternative perspectives on whether or not branchless_lower_bound is truly superior to std::lower_bound in all cases.
Overall, while informative and well-written, readers should approach this article with some caution and consider seeking out additional sources before making any decisions about which binary search algorithm to use.