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

Replace unnecessary Vec with a simple flag in InputMap::which_pressed() #455

Merged

Conversation

Shute052
Copy link
Collaborator

Objective

The InputMap::which_pressed() function is invoked by the update_action_state() system every tick when the corresponding Actionlike is enabled. Currently, for press state checking, it unnecessarily accumulates a temporary vector, causing avoidable performance losses.

Solution

Replace the temporary inputs vector with a simple pressed flag to enhance the efficiency of press state checking.

Copy link
Contributor

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this looks good :) I think that this was a relic from when I was trying to track reasons_pressed.

@alice-i-cecile alice-i-cecile added code-quality Make the code faster or prettier performance Code go brrr labels Jan 29, 2024
@alice-i-cecile alice-i-cecile marked this pull request as ready for review January 29, 2024 02:34
@alice-i-cecile
Copy link
Contributor

Is there anything else you'd like to do before I merge this in?

@Shute052
Copy link
Collaborator Author

Is there anything else you'd like to do before I merge this in?

Nope, perhaps no further actions

@alice-i-cecile alice-i-cecile merged commit 2601c01 into Leafwing-Studios:main Jan 29, 2024
4 checks passed
@Shute052 Shute052 deleted the refactor_which_pressed branch January 31, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality Make the code faster or prettier performance Code go brrr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants