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

item_location: add a parent_pocket() helper #64178

Merged
merged 1 commit into from
Mar 13, 2023

Conversation

andrei8l
Copy link
Contributor

@andrei8l andrei8l commented Mar 12, 2023

Summary

None

Purpose of change

Squeeze some more performance out of the inventory UI for the very common case of containers with only one pocket.

Describe the solution

Add an item_location::parent_pocket() helper that caches the parent pocket and uses a shortcut instead of running the very expensive item::contained_where() in the common case of only one pocket.

Use this helper wherever possible, most notably in inventory_entry::is_hidden()

Describe alternatives you've considered

N/A

Testing

Using Eagle Mountain-trimmed.tar.gz that recreates the scenario from #64139 (comment)

scen

Verify that the inventory UI still looks and functions exactly the same (collapsing etc)

Before:
before

perf

before-perf

After:
after

perf

after-perf

Additional context

N/A

@andrei8l andrei8l force-pushed the inv_ui-faster-is_hidden branch from b0c79b4 to 5d51407 Compare March 12, 2023 04:54
@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Info / User Interface Game - player communication, menus, etc. Items: Containers Things that hold other things astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Mar 12, 2023
@andrei8l andrei8l force-pushed the inv_ui-faster-is_hidden branch from 5d51407 to 4226c80 Compare March 12, 2023 12:06
that caches the parent pocket so you don't have to run
contained_where() everytime
@andrei8l andrei8l force-pushed the inv_ui-faster-is_hidden branch from 4226c80 to 504ba4a Compare March 12, 2023 16:39
@dseguin dseguin merged commit bc2e579 into CleverRaven:master Mar 13, 2023
@andrei8l andrei8l deleted the inv_ui-faster-is_hidden branch March 13, 2023 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Info / User Interface Game - player communication, menus, etc. Items: Containers Things that hold other things json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants