Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: uniqueItemsPlayer #6594

Closed
wants to merge 1 commit into from
Closed

WIP: uniqueItemsPlayer #6594

wants to merge 1 commit into from

Conversation

PabstMirror
Copy link
Contributor

@PabstMirror PabstMirror commented Sep 23, 2018

Stripped down fast version that's just for ace_player
20 items, 4 unique (ammo bearer unit placed in editor)
"ACE_CableTie" in (items player) 0.0034 ms
"ACE_CableTie" in (player call ace_common_fnc_uniqueItems) 0.0056 ms
"ACE_CableTie" in (call ace_common_fnc_uniqueItemsPlayer) 0.0024 ms

@mharis001
Copy link
Member

Perfect. Even faster 👍

@dedmen
Copy link
Contributor

dedmen commented Sep 23, 2018

~You are only creating the cache once. Never clearing it?~~

GVAR(uniqueItemsCache) = nil;

private _items = GVAR(uniqueItemsCache);

@PabstMirror
Copy link
Contributor Author

PabstMirror commented Oct 1, 2018

Actually implementing this is going to be a little tricky, and might not be worth it due to making functions less usable.

Example https://github.com/acemod/ACE3/blob/master/addons/captives/functions/fnc_canApplyHandcuffs.sqf#L23

{"ACE_CableTie" in (_unit call EFUNC(common,uniqueItems))} &&

Function is private and in every use we have it's only called when _unit is player.
Changing to in (call ace_common_fnc_uniqueItemsPlayer) would break the function if it was ever used on a remote _unit.

So it should be safe (assuming no one else is using this function in a unintended way), but I'm not sure if the trivial performance gains are worth it.

@thojkooi thojkooi changed the title uniqueItemsPlayer WIP: uniqueItemsPlayer Nov 18, 2018
@PabstMirror
Copy link
Contributor Author

probably not worth it, closing for now

@PabstMirror PabstMirror closed this Oct 8, 2019
@dedmen
Copy link
Contributor

dedmen commented Oct 9, 2019

Actually implementing this is going to be a little tricky

Could add a _unit isEqualTo ACE_Player check in fnc_uniqueItems, and switch to the extra fast cached variant in that case.
Might make it overall slower though, don't know the distribution between self and other unit calls.

@jonpas jonpas deleted the highSpeedItems branch June 24, 2023 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants