| 08-08-2008, 09:01 AM | #1 |
I know using an array variable is slower than using a not array variable. But how much ? for example : JASS:globals integer array Ia integer I endglobals function test takes integer i returns nothing set Ia[i]=5 call BJDebugMsg(I2S(Ia[i])) call BJDebugMsg(I2S(Ia[i]+1)) call BJDebugMsg(I2S(Ia[i]+2)) set Ia[i]=0 endfunction Yes i know this example is useless and not safe, that's not the question. Should it be faster if i do that : JASS:function test takes integer i returns nothing set Ia[i]=5 set I=Ia[i] call BJDebugMsg(I2S(I)) call BJDebugMsg(I2S(I+1)) call BJDebugMsg(I2S(I+2)) set Ia[i]=0 endfunction |
| 08-09-2008, 05:31 AM | #2 |
IMO, yes, since it doesn't require an array look-up every time it is used. |
| 08-09-2008, 10:09 AM | #3 |
In this case (and most other cases) it doesn't matter at all, compared to I2S+BJDebugMsg the array lookup costs almost nothing. |
| 08-09-2008, 10:18 AM | #4 | |
Quote:
Ok, but it's still faster ? I mean if i use in a hudge loop or a short periodic timer should i use a non array variable ? In general how many used of an array variable justify the using of an array non variable ? (2,3 , more ?) EDIT I ask that because i can't use japi. I've uncomment these lines on the ongameload.lua: loaddll("bin\\japi.dll") loaddll("bin\\nativepack.dll") I can save a map with japi natives but when i test it's back to the warcraft menu. |
| 08-09-2008, 11:12 AM | #5 |
~(1.5-2) times locals are faster but it takes decent allocation time. |
| 08-09-2008, 11:13 AM | #6 |
The deviation is probably so minor that nobody will ever make a big deal out of it. |
| 08-10-2008, 01:46 AM | #7 | |
Quote:
|
| 08-11-2008, 08:07 AM | #8 | |
Quote:
|
| 08-11-2008, 01:59 PM | #9 |
When I recently asked around what was faster, allocating a handle or allocating a struct (a difference much more significant than what you're asking), PipeDream encouraged me not to care. I extend the same suggestion to you. |
| 08-11-2008, 03:11 PM | #10 | |
Quote:
|
