News for hackers. Stuff that matters.
Re:Falsehoods programmers believe about null pointers by toast0 on Saturday February 01, 2025 @01:00AM (#42896071)
Sure, the cost of the check is small, and if you actually hit a null pointer, the cost is much higher if it's flagged by the MMU instead of a simple check.

But you're saving probably two bytes in the instruction stream for the test and conditional jump (more if you don't have variable length instructions), and maybe that adds up over your whole program so you can keep meaningfully more code in cache.

Re:Falsehoods programmers believe about null pointers by LorenPechtel on Saturday February 01, 2025 @09:58AM (#42898783)
More important is the branch predictor. Sometimes you take the hit of a failed predict and you also stuck another entry in the predictor table, making it more likely some other code will suffer a failed branch predict.