HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

bj_forLoopAIndex

10-21-2007, 03:08 PM#1
cohadar
is using bj_forLoopAIndex faster than using local integer for looping?
are there any side effects?
10-21-2007, 03:51 PM#2
MaD[Lion]
its all the same :P just tat using bj_ thingy then u wont need to declare it again, since its declared at init
10-21-2007, 05:23 PM#3
cohadar
I am not sure about that, it would be the same if bj_'s are just global variables,
but I am not sure they are.
10-21-2007, 05:31 PM#4
MaD[Lion]
one think i can think of is that they are global variable, and that they are declared at init. therefore it will be faster to use them, than to declare new local
10-21-2007, 05:47 PM#5
Captain Griffen
Globals and locals (non-arrays) are so rediculously cheap that discerning any difference is impossible, and also pointless.
10-21-2007, 06:53 PM#6
cohadar
Yeah you are probably right,
I just wante to know if there is anything special about bj_'s

Like for example GetTriggerUnit() is preserved after waits...
10-21-2007, 07:08 PM#7
Vexorian
globals are slower than locals and are... globals, using them as loop counters is not "cute".

Kind of began to post pleanty of time before the replies, the thing is that all bj_ are just global variables and don't get "preserved" by waits or anything like that.
10-21-2007, 07:28 PM#8
cohadar
Well that is what I needed a definite answer.
10-21-2007, 08:46 PM#9
MaD[Lion]
only vex have the skill for tat..
10-22-2007, 07:50 AM#10
Silvenon
Writing bj_forLoopAIndex every time when looping is kinda annoying too.
10-22-2007, 05:10 PM#11
Strilanc
Use locals. Use locals. USE LOCALS.

Ignoring that vex says they are faster, and that "bj_forLoopAIndex" will make your code stretch off the screen: global iterators would cause you incredible pain.

If you use global iterators, calling a custom function may change your iterator. That means you need to remember every iterator every function uses. If you forget one, and call that function from a loop using the wrong iterator, your loop will behave erratically and it will take at least 10 minutes to find the problem; IF YOU EVEN NOTICE IT. I can not emphasize enough how bad this is once your map starts getting complex.

There is a reason global variables get a lot of hate.
10-22-2007, 06:45 PM#12
cohadar
nah, I think I will use globals just to piss ppl off.
10-22-2007, 08:43 PM#13
Silvenon
Quote:
Originally Posted by cohadar
nah, I think I will use globals just to piss ppl off.

Amen.
10-22-2007, 08:44 PM#14
PitzerMike
Freedom of choice above all!