lali.b97@gmail.com wrote:
> Somewhere in a tutorial i read that if statement has performance
> overheads as code within the if statement cannot take benefit of
> pipeling of microprocessor and also that the compiler cannot
> agressively optimize that code.
>
>>From that day onwards i have been trying to avoid if statement withing
> my functions as much as possible and also try to have minimum code
> withing if block.
You are making the classic mistake: Believing something you read and
starting blindly doing it that way without actually *testing* it in
practice.
I may well be that your avoidance of the if clause may in fact be
producing slower code. However, since you haven't tested both
possibilities in your programs, you can't know.
Anyways, in the vast majority of cases such a small potential
optimization doesn't matter at all. Usually less than 1% of a program
which performs heavy calculations would require such low-level
optimization (if even that much).