They have different meanings.
The first example will stop when the condition is met.
The second will test $x
twice.
You may want to make your second if
an else if
. This will mean the block will be skipped as soon as one condition evaluates to true.
But if you are wondering which one is fastest, you should instead think which one most effectively communicates what I want to do. They will both most probably end up as conditional jumps in the target architecture.
Premature optimisation... (you know the rest :P )
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…