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

A set of general optimisations #916

Merged
merged 19 commits into from
Feb 12, 2024
Merged

A set of general optimisations #916

merged 19 commits into from
Feb 12, 2024

Conversation

shawnlaffan
Copy link
Owner

First few commits are focused on _calc_abc but later commits span other parts of the system.

No need to build a large array when we can process as we go.
This uses les memory and allows a few faster approaches.
We can use direct assignment of the whole hash
in first element_list iter, thus avoiding
some looping and slicing.
It was being used to get the element lists,
but these are passed anyway and calc_abc returns
hashes instead of arrays.
This is an optimised variant of _calc_abc that
triggers when there is only one item in
$args{element_list 1} and no other lists are passed.

In such cases there is no need to run many of
the checks and the results can be more direct.

This is also the most common use case.
No need to search for the set of list indices
every time when this does not change.
Will make a small speed difference in some cases.
BaseStruct::get_element_property_keys caches its return value,
and we change its cache key to a state var.
We can avoid a lot of work if we know the
labels have no range property.
One autovivifies, the other does not.
These labels will all be swapped anyway so
there is no need to subset the list.

A late update to #822 after the main PR.
@shawnlaffan shawnlaffan merged commit 61bbcde into master Feb 12, 2024
8 checks passed
@shawnlaffan shawnlaffan deleted the optimise_calc_abc branch February 12, 2024 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant