Page MenuHomeFeedback Tracker

BIS_fnc_returnChildren optimization
Acknowledged, WishlistPublic

Description

The functions calls bis_fnc_returnChildren on the "depth - 1" level, even if the current depth is 0. This unnecessarily increases the script run time.

Also, the _lastOnly parameter works the other way around, so it should be _allTiers (or something like this), but upgrading its description would be enough.
https://community.bistudio.com/wiki/BIS_fnc_returnChildren

edit: also using set instead of pushback

Details

Legacy ID
1432774217
Severity
None
Resolution
Open
Reproducibility
Always
Category
Scripting
Steps To Reproduce

Get into editor, open up the debug console

test = ([(configfile >> "CfgVehicles" >> "b_soldier_f"), 0, false] call BIS_fnc_returnChildren);

Press the performance test button. It should be around 16ms

Put (count test) into a watchlist to see the returned array count.

Now go into the functions editor, find the "returnChildren" function. Copy the whole test, create a custom function, and put it into an editor.

Put a if (_depth > 0) then { }; around the [_subClass,_depth - 1,_lastOnly,false] call BIS_fnc_returnChildren; line

save it, make it callable like the original one.

Test the same stuff with it.

The result should be around 3ms.

see at the (count test) watchlist, it's the same amount of config classes returned. Try it with other parameters, get more levels etc. It will be always faster with the additional if check.

Event Timeline

Gippo edited Steps To Reproduce. (Show Details)Aug 8 2015, 11:32 PM
Gippo set Category to Scripting.
Gippo set Reproducibility to Always.
Gippo set Severity to None.
Gippo set Resolution to Open.
Gippo set Legacy ID to 1432774217.May 8 2016, 12:30 PM
Gippo edited a custom field.
Gippo added a subscriber: Gippo.May 8 2016, 12:30 PM
Gippo added a comment.Aug 13 2015, 9:02 AM

Edit note: replaced fn_common_returnChildren in the reproduction to BIS_fnc_returnChildren. (was copy pasted from my modified code )