Comment

Comment by Tiddles-the2nd

The check isn't important; what's important is being predictable so the CPU can guess which way the check will go. I don't know exactly how it works, but after the first couple of loops, the predictor will assume it's always going to end up in the loop and make that the fast path. It may guess wrong the first couple of loops, and the last check wrong, but the other 997 will be correct.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton