will reassigning non-static each iteration loop impact performance?


consider following twin ways minute loop java list contains given value:



style 1



boolean found = false;
for(int i = 0; i < list.length && !found; i++)
{
if(list[i] == testval)
found = true;
}


style 2



boolean found = false;
for(int i = 0; i < list.length && !found; i++)
{
found = (list[i] == testval);
}


the twin equivalent, nonetheless i always impression 1 since 1) i some-more readable, 2) i am presumption reassigning found false hundreds times feels take some-more time. i am wondering: second audacity true?



nitpicker's corner




  • i am good wakeful box beforehand optimization. doesn't meant isn't something useful know.

  • i don't caring impression cruise some-more readable. i am wholly prying presumably opening chastisement compared other.

  • i know impression 1 advantage permitting also put break; matter if block, nonetheless i don't care. again, doubt performance, style.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?