> Does the C compiler optimise out the branch from the if() statement?
In a function as simple as this, the existence of a branch may be as fast or faster than a version without as the CPU has the opportunity to eliminate register/memory modification via branch prediction.
So even if a compiler does not optimize out this particular if construct, there is a good chance the CPU will.
In a function as simple as this, the existence of a branch may be as fast or faster than a version without as the CPU has the opportunity to eliminate register/memory modification via branch prediction.
So even if a compiler does not optimize out this particular if construct, there is a good chance the CPU will.