Check if debuff exists in game
View Single Post
08-20-14, 08:39 AM
A Pyroguard Emberseer
Join Date: Mar 2010
Originally Posted by
There's no benefit. As a matter of good practice, you should limit variables to the lowest scope in which they are needed. If they're only used inside a loop, they should only exist inside that loop.
It's not always true, keeping a local var inside the for loop:
- Create the variable
- Assign memory address to it.
- Allocate the memory for it.
- Then upvalue it with something.
However if you keep it outside the for loop, then the first 3 step is gonna run when you load the addon and only then, not recreating them at each loop, make the for loop run faster, since it only gonna overwrite whatever it can find the assigned memory address.
(Quick note with the current memory modules (DDR2-DDR3) overwriting a value is 30% faster then completely clear a memory block clean.)
However accessing a variable outside the loop also take some extra time.
You don't really make the whole code run faster, however you spread the workload into more modules, making the CPU/Memory peak usage lower.
More info in this thread:
Last edited by Resike : 08-20-14 at
View Public Profile
Send a private message to Resike
Find More Posts by Resike