Related Question: Incrementing: x++ vs x += 1
I have code that is like this:
int lastValidIndex = -1;
for(int i = 0; i < limit; i++){
if (condition)
lastValidIndex++;
else
break;
}
And I was wondering if it would be faster to just assign lastValidIndex
to i
or to increment it. I'm guessing it would be faster to just assign so the computer doesn't have to add, but I'm not sure.