perf: skip the shortcut walk for modifier sets no shortcut uses - #393
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Typing capital letters, shifted symbols and Option characters gets cheaper per key. Those key presses used to check all 57 shortcut actions one by one, even though no shortcut uses Shift alone or Option alone. Now the app keeps the set of modifier combinations that any shortcut starts with, and skips the whole check when a key press uses a combination outside that set.
Plain typing is unchanged: it already skipped the check.
How it stays safe
settings.jsonreload. Until it is first built, nothing is skipped.Measured
Debug build, 20 batches of 1000 synthetic key presses, median per key, 3 runs each (numbers are from the whole shortcut handler).
Debug numbers overstate absolute cost; the ratio is the point. The benchmark harness is not included.
Test plan
AppDelegateShortcutRoutingTestspass in CI.