HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

ForGroup vs Loop

03-16-2007, 01:04 AM#1
FatalError
Are there any negative side-effects of using a loop versus using ForGroup() to loop through all the units of a group? It seems that looping is so much easier, and it seems faster, since you can exit the loop when you found the unit you were looking for. However, I rarely see loops being used. Why? Is ForGroup considerably faster or something?
03-16-2007, 01:11 AM#2
ixmike88
Yes, from what I know the loop is much slower than ForGroup.
03-16-2007, 04:01 AM#3
PipeDream
Depends on how you're using it. The fastest cases are with loops, but just use ForGroup, it's reasonable for all use cases and easy to implement.
03-16-2007, 10:51 PM#4
FatalError
Quote:
Originally Posted by PipeDream
Depends on how you're using it. The fastest cases are with loops, but just use ForGroup, it's reasonable for all use cases and easy to implement.
My understanding is that if you're looking for a unit in a group, then loops would be faster because you can stop when the unit is found, am I correct?

I just hate using ForGroup because it's so annoying to have an extra function and to have to pass variables somehow, usually with GameCache, etc etc. Loop seems so much easier, I was just wondering if there was some big side-effect from using them.

Anyway, thanks.
03-16-2007, 11:07 PM#5
Captain Griffen
Why, oh why, would you use gamecache? Just use globals, since it is instantaneous use. ForGroup is faster for full itinerations, but slower if you want to exit at some point.
03-17-2007, 02:28 AM#6
PipeDream
Well there's a little more to it than that in that loops are faster if you don't need the group again.