News for hackers. Stuff that matters.
Re:Why is it faster to process a sorted array than an unsort... by wyager on Friday September 15, 2017 @11:08AM (#15257744)
Sorting is going to be more expensive than mis-predicting every item in the array (since sorting inherently involves multiple rounds of conditional swaps, getting it wrong a lot of the time on random data). The trick in the SO post is that they use the same sorted data tens of thousands of times.
Re:Why is it faster to process a sorted array than an unsort... by repsilat on Friday September 15, 2017 @11:18AM (#15257827)
You can partition the list with zero branches (aside from the loop test.) You don't need to sort it.

(Though, of course, the original algorithm can be written in a one-pass branchless fashion anyway, so the point is kinda moot.)