News for hackers. Stuff that matters.
Re:Binary Search Reconsidered (2018) by tsimionescu on Friday December 25, 2020 @03:48PM (#25538920)
What do you consider not to be clean? I dislike the fact that it returns a copy of the key, but otherwise it seems quite explicit code that doesn't needlessly get bogged down in error prone integer arithmetic.
Re:Binary Search Reconsidered (2018) by klyrs on Friday December 25, 2020 @04:57PM (#25539355)
As I've pointed out in another comment, this implementation loses track of the index. It looks clean enough to my un-rusty eye, but it sacrifices functionality in favor of hiding the arithmetic behind a slice.

And __s's comment does it best: use the standard library. And that's a nice implementation (despite the unsafe stuff), which tracks the basepoint and size to keep the arithmetic clean.