Quote:
What do you mean with this? could you give me an example? I get the fact that the array size will never change, but why do i need to cache it?
|
for(initialization; condition; step)
In a loop, the condition is tested on each iteration.
Your condition is something like: i < ArraySize(). What happens is after each iteration the plugin has to call ArraySize in order to be able to compare it with "i".
If you cache it into a variable then you can use that in the loop condition and avoid calling the native for each step.
Code:
i = 0: execute your code, call ArraySize, compare with i, increment
i = 1: execute your code, call ArraySize, compare with i, increment
...
i = k: execute your code, call ArraySize, compare with i, increment
...
With caching:
i = 0: execute your code, compare variable with i, increment
i = 1: execute your code, compare variable with i, increment
...
i = k: execute your code, compare variable with i, increment
...
You don't need to do that for loops using sizeof and regular arrays, because their size is known at compile time.
__________________