0

Consider the following code:

foreach ($products as $product) {
    if (some_long_condition()) {
        continue;
    } 
    do_stuff();

Which would be faster, having a condition with a continue, or negating the condition itself? Is there a difference at all in terms of performance, or is it just syntactic sugar?

Exec
  • 407
  • 6
  • 18

1 Answers1

1

This is exactly the same, a boolean comparison. The compiler doesn't make a difference here.

Daniel
  • 795
  • 1
  • 10
  • 25