I am tagging this as C, though it certainly applies to many languages. The reason for this is the part of the question dealing with optimization, which is compiler dependent.
Sometimes we encounter situations like this in programs:
if(bob == 42)
{
/* ... */
return;
}
else
{
/* ... */
}
The else
block here is not strictly necessary, as you can probably see. The same thing also occurs with other program-flow-controlling structures; some "ordinary" constructs are made redundant because of special conditions. The question is: Is there a reason to write these redundant blocks of code? Clarity? Could it possibly help a compiler with optimizations, if the situation was complex enough?