
Software Optimization Guide for AMD64 Processors | 25112 Rev. 3.06 September 2005 |
Because the odds that the animal name begins with a ‘y’ are comparatively low, it is better to put that operand first:
if ((*p == 'y') && (strlen(p) > 4)) { ... }
Example 2
In the following code (assuming a uniform random distribution of i), the operands of are not arranged for quick expression evaluation because the first operand is not the condition most likely to be true:
unsigned int i;
if ((i < 4) (i & 1)) { ... }
Because it is more likely for the
if ((i & 1) (i < 4)) { ... }
18 | C and C++ | Chapter 2 |