You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Object.entries + map allocates a copy of the list twice.
And it ends up calling a tiny function over and over.
Using a boring nested for loop and an array
cuts hat allocation time by about 35%.
Removing items from an array one at a time is quadratic (triangular).
However, N is capped at the number of hats a user has (per grapheme),
which is fundamentally capped at a fairly small number.
And copying an array is typically a highly optimized operation.
This bit of hot code showed up in a profile from user saidelike on
Slack.
I have tested that this does not modify behavior
on a branch with golden hat tests.
## Checklist
- [/] I have added
[tests](https://www.cursorless.org/docs/contributing/test-case-recorder/)
- [/] I have updated the
[docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and
[cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet)
- [/] I have not broken the cheatsheet
---------
Co-authored-by: Pokey Rule <[email protected]>
0 commit comments