Skip to content

Commit

Permalink
Replace all use of count as a forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror committed Oct 18, 2019
1 parent 1032469 commit b2829e1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 22 deletions.
6 changes: 2 additions & 4 deletions addons/common/init_perFrameHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ GVAR(waitUntilAndExecArray) = [];
if (diag_tickTime > _delta) then {
_x set [2, _delta + _delay];
[_args, _handle] call _function;
false
};
} count GVAR(perFrameHandlerArray);
} forEach GVAR(perFrameHandlerArray);


// Execute wait and execute functions
Expand Down Expand Up @@ -64,8 +63,7 @@ GVAR(waitUntilAndExecArray) = [];
// Execute the exec next frame functions
{
(_x select 0) call (_x select 1);
false
} count GVAR(nextFrameBufferA);
} forEach GVAR(nextFrameBufferA);
// Swap double-buffer:
GVAR(nextFrameBufferA) = GVAR(nextFrameBufferB);
GVAR(nextFrameBufferB) = [];
Expand Down
9 changes: 3 additions & 6 deletions addons/jr/fnc_compatibleItems.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,17 @@ if (isNil "_compatibleItems") then {
if (isArray _cfgCompatibleItems) then {
{
_compatibleItems pushBackUnique _x;
nil
} count getArray _cfgCompatibleItems;
} forEach getArray _cfgCompatibleItems;
} else {
if (isClass _cfgCompatibleItems) then {
{
if (getNumber _x > 0) then {
_compatibleItems pushBackUnique configName _x;
};
nil
} count configProperties [_cfgCompatibleItems, "isNumber _x"];
} forEach configProperties [_cfgCompatibleItems, "isNumber _x"];
};
};
nil
} count configProperties [_cfgWeapon >> "WeaponSlotsInfo", "isclass _x"];
} forEach configProperties [_cfgWeapon >> "WeaponSlotsInfo", "isclass _x"];

GVAR(namespace) setVariable [_weapon, _compatibleItems]; //save entry in cache
} else {
Expand Down
9 changes: 3 additions & 6 deletions addons/statemachine/fnc_createFromConfig.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ private _stateMachine = [_list, _skipNull] call FUNC(create);
GET_FUNCTION(_onStateLeaving,_x >> "onStateLeaving");
[_stateMachine, _onState, _onStateEntered, _onStateLeaving, _state] call FUNC(addState);

false
} count (configProperties [_config, "isClass _x", true]);
} forEach (configProperties [_config, "isClass _x", true]);

// We need to add the transitions in a second loop to make sure the states exist already
{
Expand All @@ -59,10 +58,8 @@ private _stateMachine = [_list, _skipNull] call FUNC(create);
[_stateMachine, _state, _targetState, _events, _condition, _onTransition, _transition] call FUNC(addEventTransition);
};

false
} count (configProperties [_x, "isClass _x", true]);
} forEach (configProperties [_x, "isClass _x", true]);

false
} count (configProperties [_config, "isClass _x", true]);
} forEach (configProperties [_config, "isClass _x", true]);

_stateMachine
3 changes: 1 addition & 2 deletions addons/xeh/fnc_addClassEventHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ _entities = _entities arrayIntersect _entities; // entities can return duplicate
};
};
};
true
} count _entities;
} forEach _entities;

// define for units that are created later
private _events = EVENTHANDLERS(_eventName,_className);
Expand Down
4 changes: 2 additions & 2 deletions addons/xeh/fnc_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ GVAR(EventsLowercase) = [];
FUNC(Init) = compileFinal (_header + "(_this select 0) call CBA_fnc_initEvents; (_this select 0) call CBA_fnc_init");
} else {
if (_x isEqualTo "HitPart") then {
FUNC(HitPart) = compileFinal (_header + format ['{call _x; nil} count ((_this select 0 select 0) getVariable QGVAR(%1))', _x]);
FUNC(HitPart) = compileFinal (_header + format ['{call _x} forEach ((_this select 0 select 0) getVariable QGVAR(%1))', _x]);
} else {
missionNamespace setVariable [
format [QFUNC(%1), _x],
compileFinal (_header + format ['{call _x; nil} count ((_this select 0) getVariable QGVAR(%1))', _x])
compileFinal (_header + format ['{call _x} forEach ((_this select 0) getVariable QGVAR(%1))', _x])
];
};
};
Expand Down
3 changes: 1 addition & 2 deletions addons/xeh/fnc_startFallbackLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ GVAR(fallbackRunning) = true;
{
// don't run init and initPost event handlers on objects that already exist
SETINITIALIZED(_x);
true
} count (entities [[], [], true, true]);
} forEach (entities [[], [], true, true]);

GVAR(entities) = [];

Expand Down

0 comments on commit b2829e1

Please sign in to comment.