I've created a loop where a variable is used to test if the current run-through of the loop is the first one. Its fairly simple:
$firstrun = true;
while(condition){
  if($firstrun)
    // Do this
  else
    // Do that
  // Change $firstrun to false
}
I was just wondering (mostly out of curiosity because I'm it makes no real noticeable difference), when I need to change $firstrun to false, would be more efficient to test if the variable is true before  assigning it to false or simply reassign it to false during each run-through?
Ex:
$firstrun = true;
while(condition){
  if($firstrun)
    // Do this
  else
    // Do that
  if($firstrun)
    $firstrun = false;
}
or simply
$firstrun = true;
while(condition){
  if($firstrun)
    // Do this
  else
    // Do that
  $firstrun = false;
}
PS:
I guess this is a bad example also, because it would be most efficient to throw the reassignment of $firstrun in with the original condition, but as I said this is out of curiosity so I guess just pretend that is not an option for some reason.
PSS: I was coding in PHP when this idea hit me, but I'm guessing the solution would be language agnostic. Just thought I would throw that in there in case it does for some reason matter.
So ultimately, which is faster, condition testing or variable assignment?
 
     
     
    