On 5/18/26 13:57, Christoph Hellwig wrote:
On Mon, May 18, 2026 at 01:40:18PM +0100, Pavel Begunkov wrote:
When that is really a performance critical path then you can use the likely() and unlikely() macros to give the compiler the hint which one to prefer.
That might be more penalising than placing them in the right order, and it might be fine as it's new and all that, but it's not a clear cut as it's definitely not created to be a slow path.
Yes. Whatever the caller is using at a given time is the fast path here, and dynamic branch prediction in modern cpus handles this really well.
TBH, not sure why we're bike shedding such things, is it somewhere in the code style?
It makes reading the code annoying, so it better have a good reason. Now for a single conditional it's not much of an issue, but these things tend to pile up and then start to get really annoying. Always write your code the most straight forward way unless you have a good reason not to.
For me, having the most common case first is more natural and readable, but I'm going to flip it just to avoid spending more time here.