Open
Conversation
This reduces the complexity of the comparison and gets rid of the heap allocation on every match. Benchmark before/after (`go test -bench . -benchtime 3s -count 5 -benchmem`): ``` name old time/op new time/op delta Matches/success-32 66.9ns ± 1% 15.7ns ± 0% -76.47% (p=0.016 n=5+4) Matches/fail-32 27.9ns ± 0% 12.4ns ± 2% -55.70% (p=0.016 n=4+5) name old alloc/op new alloc/op delta Matches/success-32 5.00B ± 0% 0.00B -100.00% (p=0.008 n=5+5) Matches/fail-32 0.00B 0.00B ~ (all equal) name old allocs/op new allocs/op delta Matches/success-32 1.00 ± 0% 0.00 -100.00% (p=0.008 n=5+5) Matches/fail-32 0.00 0.00 ~ (all equal) ```
Contributor
Author
|
NB: I could imagine the map from string to tea.Key being defined in the bubbletea package directly. If you prefer that, let me know. |
Contributor
I think that makes sense and is probably nicer next to the other |
Contributor
|
Whoa! This is awesome @knz, solid optimization! |
Contributor
Author
Ok see charmbracelet/bubbletea#491 Then to merge this PR I'll need a release number for the go.mod update. |
This was referenced Oct 7, 2022
Contributor
|
@muesli Is this good to merge? |
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.
Fixes #262.
cc @meowgorithm @muesli