5 ms·
In C, there are ways you can get the optimizer to turn if-based error handling into something that only spends one or two instructions; using __builtin_expect[0
by haldean 10y ago
In C, there are ways you can get the optimizer to turn if-based error handling into something that only spends one or two instructions; using __builtin_expect[0] can decrease the cost of a condition by letting the branch predictor pick the "right" thing to expect. That way you end up only paying the price of the branch (and maybe the jump) instructions without any pipeline flushes or stalls.
[0]: http://blog.man7.org/2012/10/how-much-do-builtinexpect-likely-and.html http://blog.man7.org/2012/10/how-much-do-builtinexpect-likel...