I am sure there is a term for the following bit of refactoring, but I can't remember it and my Google-fu is failing me!
The refactor moves if statements to where they are going to have most impact, for example changing this
$test = someFunctionThatReturnsABool();
for($x = 0; $x < 10000; $x++) {
if ($test) {
echo $x;
}
}
To this
$test = someFunctionThatReturnsABool();
if ($test) {
for($x = 0; $x < 10000; $x++) {
echo $x;
}
}