Code optimization vs readable code
Assuming you have a code such as this:
foreach ($products as $product) {
process(product);
if(somecondition){
doSomething(product);
}
}
How bad would you consider this form of refactoring?
foreach ($products as $product) {
process(product);
}
foreach ($products as $product) {
if(somecondition){
doSomething(product);
}
}
The reason I like it is because you can extract both things in separate methods, and I do not feel that the performance is hurt that bad...