- Joined
- Aug 13, 2007
- Messages
- 309
W H O --- W O U L D --- W I N --- I N --- F I G H T ?
Contestants:
gt_UnitLoops_Func vs gt_UnitLoops2_Func
(which one is more efficient / better?)
Contestants:
gt_UnitLoops_Func vs gt_UnitLoops2_Func
JASS:
// WHO WOULD WIN IN FIGHT?
bool gt_UnitLoops_Func (bool testConds, bool runActions) {
unitgroup lv_ug = UnitGroupEmpty();
unit lv_u;
// We shall pretend we're using a valid unit group that
// actually has units in it.
UnitGroupLoopBegin(lv_ug);
while (!UnitGroupLoopDone()) {
lv_u = UnitGroupLoopCurrent();
// Things we do with our unit go here.
UnitGroupLoopStep();
}
UnitGroupLoopEnd();
return true;
}
bool gt_UnitLoops2_Func (bool testConds, bool runActions) {
unitgroup lv_ug = UnitGroupEmpty();
int lv_i = 1;
unit lv_u;
// We shall pretend we're using a valid unit group that
// actually has units in it.
while(lv_u != null) {
UnitGroupUnit(lv_ug, lv_i);
// Things we do with our unit go here.
lv_i += 1;
}
return true;
}