mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Optimise spectator loops (#6021)
* Optimise spectator loops `count` is only quicker than `forEach` when the final command returns a boolean or nil. `forEach` is quicker if the final command returns any other data type. * Use `forEach` instead of `count`
This commit is contained in:
parent
4eb7868f1a
commit
dbe6a04e8a
@ -12,7 +12,7 @@
|
||||
* 3: Respawn Delay <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None <NIL>
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [bob, kevin, 3, 6] call ace_spectator_fnc_respawnTemplate
|
||||
|
@ -72,9 +72,7 @@ if !(GVAR(uiMapVisible)) then {
|
||||
|
||||
// Draw icon
|
||||
drawIcon3D _icon;
|
||||
|
||||
nil // Speed loop
|
||||
} count GVAR(iconsToDraw);
|
||||
} forEach GVAR(iconsToDraw);
|
||||
END_COUNTER(drawTags);
|
||||
};
|
||||
|
||||
@ -119,13 +117,9 @@ if !(GVAR(uiMapVisible)) then {
|
||||
drawLine3D [_oldLoc, _locNew, _colorNew];
|
||||
};
|
||||
_oldLoc = _locNew;
|
||||
|
||||
nil // Speed loop
|
||||
} count _segments;
|
||||
} forEach _segments;
|
||||
};
|
||||
|
||||
nil // Speed loop
|
||||
} count GVAR(projectilesToDraw);
|
||||
} forEach GVAR(projectilesToDraw);
|
||||
GVAR(projectilesToDraw) = _projectilesNew;
|
||||
|
||||
{
|
||||
@ -138,9 +132,7 @@ if !(GVAR(uiMapVisible)) then {
|
||||
// Store grenade for next frame
|
||||
_grenadesNew pushBack _x;
|
||||
};
|
||||
|
||||
nil // Speed loop
|
||||
} count GVAR(grenadesToDraw);
|
||||
} forEach GVAR(grenadesToDraw);
|
||||
|
||||
GVAR(grenadesToDraw) = _grenadesNew;
|
||||
END_COUNTER(drawTracers);
|
||||
|
@ -64,8 +64,7 @@ private _handledVehicles = [];
|
||||
|
||||
_map drawIcon [_vehicleTexture, _sideColor, getPosASLVisual _vehicle, 24, 24, getDirVisual _vehicle, _text, 1, 0.04, "TahomaB", "right"];
|
||||
};
|
||||
nil // Speed loop
|
||||
} count ([] call FUNC(getTargetEntities));
|
||||
} forEach ([] call FUNC(getTargetEntities));
|
||||
|
||||
// Set highlighted unit
|
||||
private _text = if (isNull _nearestEntity) then {
|
||||
|
@ -139,9 +139,7 @@ private _camPos = AGLToASL positionCameraToWorld [0,0,0];
|
||||
SETVAR(_vehicle,GVAR(firedEH),_vehicle addEventHandler [ARR_2("Fired",{_this call FUNC(handleFired)})]);
|
||||
};
|
||||
};
|
||||
|
||||
nil // Speed loop
|
||||
} count ([] call FUNC(getTargetEntities));
|
||||
} forEach ([] call FUNC(getTargetEntities));
|
||||
|
||||
GVAR(iconsToDraw) = _iconsToDraw;
|
||||
GVAR(entitiesToDraw) = _entitiesToDraw;
|
||||
|
@ -51,8 +51,7 @@ private _entities = [true] call FUNC(getTargetEntities);
|
||||
alive _x && { NEEDS_REVIVE(_x) },
|
||||
_name
|
||||
];
|
||||
nil // Speed loop
|
||||
} count _entitiesGroup;
|
||||
} forEach _entitiesGroup;
|
||||
|
||||
// Cache the info of the group itself
|
||||
private _groupTexture = [_group] call FUNC(getGroupIcon);
|
||||
@ -80,8 +79,7 @@ private _entities = [true] call FUNC(getTargetEntities);
|
||||
((_newList select _sideIndex) select 4) pushBack [_groupInfo, _unitsInfo];
|
||||
};
|
||||
};
|
||||
nil // Speed loop
|
||||
} count allGroups;
|
||||
} forEach allGroups;
|
||||
|
||||
// Whether an update to the list is required (really only if something changed)
|
||||
if !(GVAR(curList) isEqualTo _newList) then {
|
||||
@ -207,12 +205,9 @@ if !(GVAR(curList) isEqualTo _newList) then {
|
||||
_ctrl tvSetPictureColor [_path, _sideColor];
|
||||
_ctrl tvSetTooltip [_path, _tooltip];
|
||||
};
|
||||
nil // Speed loop
|
||||
} count _nestedUnitData;
|
||||
nil // Speed loop
|
||||
} count _nestedGroupData;
|
||||
nil // Speed loop
|
||||
} count _newList;
|
||||
} forEach _nestedUnitData;
|
||||
} forEach _nestedGroupData;
|
||||
} forEach _newList;
|
||||
|
||||
// Store the new list as the current list
|
||||
GVAR(curList) = _newList;
|
||||
|
Loading…
Reference in New Issue
Block a user