Skip to content

Commit

Permalink
Change all counts to forEach as the performance difference is negligi…
Browse files Browse the repository at this point in the history
…ble and can cause more issues than
  • Loading branch information
jokoho48 committed Apr 19, 2024
1 parent f7871d5 commit 3d22e8c
Show file tree
Hide file tree
Showing 52 changed files with 110 additions and 213 deletions.
3 changes: 1 addition & 2 deletions addons/CLib/3dGraphics/fn_add3dGraphics.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ private _completeGraphicsData = [];
_completeGraphicsData pushBack [_class, _start, _end, _lineColor, _code, _customCodeArgs];
};
};
nil
} count _graphicsData;
} forEach _graphicsData;

[GVAR(3dGraphicsNamespace), _id, _completeGraphicsData] call CFUNC(setVariable);
GVAR(3dGraphicsCacheBuildFlag) = GVAR(3dGraphicsCacheBuildFlag) + 1;
3 changes: 1 addition & 2 deletions addons/CLib/3dGraphics/fn_draw3dGraphics.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ if (GVAR(3dGraphicsCacheVersion) != GVAR(3dGraphicsCacheBuildFlag)) then {
};
};
};
nil
} count GVAR(3dGraphicsCache);
} forEach GVAR(3dGraphicsCache);

RUNTIME("3dGraphics")
3 changes: 1 addition & 2 deletions addons/CLib/AdvancedStateMachine/fn_addASMTransition.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ if (_sourceStateNames isEqualType "") then {
} else {
LOG("Invalid source state name passed to addASMTransition");
};
nil
} count _sourceStateNames;
} forEach _sourceStateNames;
6 changes: 2 additions & 4 deletions addons/CLib/Core/Autoload/fn_callModules.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ private _thread = 0 spawn {
_code = missionNamespace getVariable [_code, {LOG("Code not Found")}];
};
_args call _code;
nil
} count CGVAR(entryPointQueue);
} forEach CGVAR(entryPointQueue);
}, _this select 1] call CFUNC(execNextFrame);
}, [_postInit, _thread]] call CFUNC(execNextFrame);

Expand All @@ -123,8 +122,7 @@ if (didJIP) then {
[_event, _args] call CFUNC(localEvent);
};
};
nil
} count (_this select 1);
} forEach (_this select 1);
};
["loadJIPQueue", CLib_Player] call CFUNC(serverEvent);
};
3 changes: 1 addition & 2 deletions addons/CLib/Core/Autoload/fn_loadModules.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ QGVAR(receiveFunction) addPublicVariableEventHandler {
};
};
#endif
nil
} count [missionNamespace, localNamespace, uiNamespace, parsingNamespace];
} forEach [missionNamespace, localNamespace, uiNamespace, parsingNamespace];

// Update the loading screen with the progress.
_progress call BIS_fnc_progressloadingscreen;
Expand Down
8 changes: 3 additions & 5 deletions addons/CLib/Core/Autoload/fn_loadModulesServer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ private _fnc_addRequiredModule = {
{
_x call _fnc_addRequiredModule;
nil
} count _dependencies;
} forEach _dependencies;
};
};

{
_x call _fnc_addRequiredModule;
nil
} count _this;
} forEach _this;

_requiredModules = _requiredModules apply {toLower _x};

Expand All @@ -51,8 +50,7 @@ publicVariable QGVAR(LoadedModules);
if (_fullFunctionModuleName in _requiredModules || _fullFunctionModName in _requiredModules) then {
GVAR(requiredFunctions) pushBackUnique _x;
};
nil
} count (parsingNamespace getVariable QCGVAR(allFunctionNamesCached));
} forEach (parsingNamespace getVariable QCGVAR(allFunctionNamesCached));

// EH for client registration. Starts transmission of function code.
// required Function that the Client needed
Expand Down
18 changes: 6 additions & 12 deletions addons/CLib/Core/ClientAddonModuleLoader/fn_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ private _fnc_compileClientFunction = {

{
_x setVariable [_functionVarName, _fncCode];
nil
} count [missionNamespace, uiNamespace, parsingNamespace];
} forEach [missionNamespace, uiNamespace, parsingNamespace];
};

private _allClientModules = [];
Expand All @@ -54,10 +53,8 @@ private _functionTag = getText (_config >> "tag");
DUMP("Read Client Addon Module: " + _moduleName);
_allClientModules pushBackUnique _fncName;
[_filePath, _fncName] call _fnc_compileClientFunction;
nil
} count configProperties [_x, "isClass _x", true];
nil
} count configProperties [_config, "isClass _x", true];
} forEach configProperties [_x, "isClass _x", true];
} forEach configProperties [_config, "isClass _x", true];

private _init = [];
private _serverInit = [];
Expand Down Expand Up @@ -86,8 +83,7 @@ private _hcInit = [];
};
};
DUMP("Read Client Addon Function: " + _x);
nil
} count _allClientModules;
} forEach _allClientModules;

{
if (_x select 1) then {
Expand All @@ -97,8 +93,6 @@ private _hcInit = [];
_time = diag_tickTime - _time;
private _strTime = (_time * 1000) call CFUNC(toFixedNumber);
LOG("Client Addon Module Call: " + _x + " (" + _strTime + " ms)");
nil
} count (_x select 0);
} forEach (_x select 0);
};
nil
} count [[_init, true], [_serverInit, isServer], [_clientInit, hasInterface], [_hcInit, !hasInterface && !isServer]];
} forEach [[_init, true], [_serverInit, isServer], [_clientInit, hasInterface], [_hcInit, !hasInterface && !isServer]];
3 changes: 1 addition & 2 deletions addons/CLib/Core/Compile/fn_buildDependencyGraph.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ while {_modulesToSort isNotEqualTo []} do {
};
};
if (!_dependenciesLoaded) exitWith {};
nil
} count _dependencies;
} forEach _dependencies;

if (_dependenciesLoaded) then {
_sortedModuleNames pushBack _moduleName;
Expand Down
3 changes: 1 addition & 2 deletions addons/CLib/Core/Compile/fn_compile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ scopeName (_fnc_scriptName + '_Main');
LOG("Error: " + _functionName + " could not get overwritten but is different from the current version!");
};
};
nil
} count [missionNamespace, uiNamespace, parsingNamespace];
} forEach [missionNamespace, uiNamespace, parsingNamespace];

#ifdef DISABLECOMPRESSION
if (true) exitWith {};
Expand Down
9 changes: 3 additions & 6 deletions addons/CLib/Core/Compile/fn_readAllFunctions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ private _fnc_readSubModule = {
private _modulePath = +_modulePath;
_modulePath pushBack _subModuleName;
[_modPath, _modName, _moduleName, _modulePath, _x] call _fnc_checkNext;
nil
} count _children;
} forEach _children;
};

private _fnc_readFunction = {
Expand Down Expand Up @@ -65,10 +64,8 @@ DUMP("--------------------------Start CLib Function Search----------------------

{
[_modPath, _modName, _moduleName, [_moduleName], _x] call _fnc_checkNext;
nil
} count (configProperties [configFile >> "CfgCLibModules" >> _modName >> _moduleName, "isClass _x", true]);
} forEach (configProperties [configFile >> "CfgCLibModules" >> _modName >> _moduleName, "isClass _x", true]);

nil
} count (parsingNamespace getVariable QGVAR(allModuleNamesCached));
} forEach (parsingNamespace getVariable QGVAR(allModuleNamesCached));
parsingNamespace setVariable [QCGVAR(allFunctionNamesCached), GVAR(allFunctionNamesCached)];
DUMP("--------------------------End CLib Function Search---------------------------------");
3 changes: 1 addition & 2 deletions addons/CLib/Core/Compression/fn_compressString.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ _rawOutput append (_rawInput select [0, MINMATCHLENGTH]);
};

if (_inputPosition == _inputLength) exitWith {};
nil
} count _rawInput;
} forEach _rawInput;

if (_writeCache isNotEqualTo []) then {
_rawOutput pushBack _encodeFlag;
Expand Down
3 changes: 1 addition & 2 deletions addons/CLib/Core/Compression/fn_decompressString.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ private _inputPosition = MINMATCHLENGTH;
};

if (_inputPosition == _inputLength) exitWith {};
nil
} count _rawInput;
} forEach _rawInput;

toString _rawOutput
3 changes: 1 addition & 2 deletions addons/CLib/Core/ExtensionFramework/fn_extensionFetch.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ if (_result select [0, 1] == GVAR(SOH)) exitWith {

[QGVAR(extensionResult), _sender, [_senderId, _result]] call CFUNC(targetEvent);
GVAR(pendingTasks) = GVAR(pendingTasks) - 1;
nil
} count _results;
} forEach _results;
};
3 changes: 1 addition & 2 deletions addons/CLib/Core/Misc/fn_cachedCall.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ if (_timestamp < time) then {
// Erase all the cached results
{
GVAR(cachedCall) setVariable [_x, nil];
nil
} count _cacheList;
} forEach _cacheList;
// Empty the list
GVAR(cachedCall) setVariable [_varName, []];
}] call CFUNC(addEventhandler);
Expand Down
3 changes: 1 addition & 2 deletions addons/CLib/Core/Misc/fn_flatConfigPath.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ private _hierarchy = configHierarchy (_configPath);
};
};
_return pushBack _name;
nil
} count _hierarchy;
} forEach _hierarchy;

_return joinString _separator;
3 changes: 1 addition & 2 deletions addons/CLib/Core/Misc/fn_getNearUnits.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ params [

{
_return append (crew _x);
nil
} count _vehicles;
} forEach _vehicles;

[_return, CLib_Player] call CFUNC(deleteAtEntry);

Expand Down
3 changes: 1 addition & 2 deletions addons/CLib/Core/Misc/fn_modLoaded.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ params [
private _loadedMods = [];
{
_loadedMods pushbackUnique ((_x splitString "/\") select 0);
nil
} count GVAR(LoadedModules);
} forEach GVAR(LoadedModules);
(toLower _mod) in _loadedMods;
3 changes: 1 addition & 2 deletions addons/CLib/Core/Misc/fn_sanitizeString.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ private _symbols = toArray "\/*""?<>|:";
if !(_x in _symbols) then {
_array pushBack _x;
};
nil
} count (toArray _string);
} forEach (toArray _string);

toString _array
6 changes: 2 additions & 4 deletions addons/CLib/Core/Misc/fn_textTiles.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ private _contentIsStructuredText = _content isEqualType (parseText "");
];
_groupContent ctrlSetFade 0;
_groupContent ctrlCommit (random _fadeIn);
nil
} count _grids;
} forEach _grids;

[{
params ["_grids", "_contentIsStructuredText", "_sizeW", "_sizeH", "_posW", "_posH", "_fadeOut", "_onFadeOut"];
Expand All @@ -146,8 +145,7 @@ private _contentIsStructuredText = _content isEqualType (parseText "");
];
_groupContent ctrlSetFade 1;
_groupContent ctrlCommit (random _fadeOut);
nil
} count _grids;
} forEach _grids;
[{
private _display = uiNamespace getVariable "RscTilesGroup";
_display closeDisplay 0;
Expand Down
18 changes: 6 additions & 12 deletions addons/CLib/Core/MissionModuleLoader/fn_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ private _fnc_compileMissionFunction = {

{
_x setVariable [_functionVarName, _fncCode];
nil
} count [missionNamespace, uiNamespace, parsingNamespace];
} forEach [missionNamespace, uiNamespace, parsingNamespace];
};

private _allMissionModules = [];
Expand All @@ -53,10 +52,8 @@ private _functionTag = getText (_config >> "tag");
DUMP("Read Mission Module: " + _moduleName);
_allMissionModules pushBackUnique _fncName;
[_filePath, _fncName] call _fnc_compileMissionFunction;
nil
} count configProperties [_x, "isClass _x", true];
nil
} count configProperties [_config, "isClass _x", true];
} forEach configProperties [_x, "isClass _x", true];
} forEach configProperties [_config, "isClass _x", true];

private _init = [];
private _serverInit = [];
Expand Down Expand Up @@ -85,8 +82,7 @@ private _hcInit = [];
};
};
DUMP("Read Mission Function: " + _x);
nil
} count _allMissionModules;
} forEach _allMissionModules;

{
if (_x select 1) then {
Expand All @@ -96,8 +92,6 @@ private _hcInit = [];
_time = diag_tickTime - _time;
private _strTime = (_time * 1000) call CFUNC(toFixedNumber);
LOG("Mission Module Call: " + _x + " (" + _strTime + " ms)");
nil
} count (_x select 0);
} forEach (_x select 0);
};
nil
} count [[_init, true], [_serverInit, isServer], [_clientInit, hasInterface], [_hcInit, !hasInterface && !isServer]];
} forEach [[_init, true], [_serverInit, isServer], [_clientInit, hasInterface], [_hcInit, !hasInterface && !isServer]];
20 changes: 7 additions & 13 deletions addons/CLib/Core/fn_serverInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ private _fnc_readAuthorData = {
_version = str (getNumber (_configPath >> "version"));
};
_modCredits pushBackUnique [_name, _author, _authors, _url, _version];
nil
} count configSourceAddonList _this;
} forEach configSourceAddonList _this;
};
private _modClassNames = [];
{
_x call _fnc_readAuthorData;
_modClassNames pushBackUnique (configName _x);
nil
} count configProperties [configFile >> "CfgCLibModules", "isClass _x", true];
} forEach configProperties [configFile >> "CfgCLibModules", "isClass _x", true];

(configFile >> "CfgCLibModules") call _fnc_readAuthorData;

Expand All @@ -65,13 +63,11 @@ private _fnc_addModules = {
if (_module == "") then {
{
[_mod, configName _x] call _fnc_addModules;
nil
} count configProperties [(configFile >> "CfgCLibModules" >> _mod), "isClass _x", true];
} forEach configProperties [(configFile >> "CfgCLibModules" >> _mod), "isClass _x", true];
} else {
[_mod, _module] call _fnc_addModules;
};
nil
} count GVAR(LoadedModules);
} forEach GVAR(LoadedModules);

GVAR(textModules) = "Loaded Modules: <br/>";
{
Expand All @@ -84,8 +80,7 @@ GVAR(textModules) = "Loaded Modules: <br/>";
GVAR(textModules) = GVAR(textModules) + format ["<br/> %1", _name];
{
GVAR(textModules) = GVAR(textModules) + format ["<br/> - %1", _x];
nil
} count (_modules select _forEachIndex);
} forEach (_modules select _forEachIndex);
GVAR(textModules) = GVAR(textModules) + "<br/>";
} forEach _mods;

Expand All @@ -95,14 +90,13 @@ GVAR(textMods) = "Loaded Mods: <br/>";
private _authors = "";
{
_authors = _authors + format ["%1, ", _x];
nil
} count _authorsArr;
} forEach _authorsArr;
if (_authors == _author) then {
GVAR(textMods) = GVAR(textMods) + format ["<br/><a href='%4'>%1</a> by %2 Version: %5<br/>", _name, _author, _url, _version];
} else {
GVAR(textMods) = GVAR(textMods) + format ["<br/><a href='%4'>%1</a> by %2: %3 Version: %5<br/>", _name, _author, _authors select [0, (count _authors) - 2], _url, _version];
};
} count _modCredits;
} forEach _modCredits;

publicVariable QGVAR(textMods);
publicVariable QGVAR(textModules);
6 changes: 2 additions & 4 deletions addons/CLib/Events/fn_clientInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ private _codeStr = "private ['_oldValue', '_currentValue'];";
private _varName = format [QGVAR(EventData_%1), _name];
GVAR(EventNamespace) setVariable [_varName, call _code];
_codeStr = _codeStr + format ["_oldValue = %4 getVariable '%2'; _currentValue = call %1; if (_oldValue isNotEqualTo _currentValue) then { ['%5Changed', [_currentValue, _oldValue]] call %3; _oldValue = %4 setVariable ['%2', _currentValue]; };", _code, _varName, QCFUNC(localEvent), QGVAR(EventNamespace), _name];
nil
} count [
} forEach [
["player", {missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", player]}],
["currentThrowable", {currentThrowable CLib_Player}],
["currentWeapon", {currentWeapon CLib_Player}],
Expand Down Expand Up @@ -102,8 +101,7 @@ addMissionEventHandler ["Map", {
// Bind a new one and update the index in the params.
_params set [2, _currentPlayer addEventHandler [_name, _code]];
}, [_x, _code, _index]] call CFUNC(addEventHandler);
nil
} count [
} forEach [
"InventoryOpened",
"Killed",
"Respawn",
Expand Down
Loading

0 comments on commit 3d22e8c

Please sign in to comment.