4 ms·
It might hurt if you add this extra variable to every loop and at some point the array length changes within the loop. It also makes the code more verbose. This
by laurent123456 7y ago
It might hurt if you add this extra variable to every loop and at some point the array length changes within the loop. It also makes the code more verbose. This optimisation should be done like all optimisations: first you benchmark and then see if it makes sense to make this change. Most of the time there's no point doing so.