Skip to content

Commit

Permalink
perf: avoid recomputing the key representation in key.Matches
Browse files Browse the repository at this point in the history
  • Loading branch information
knz committed Aug 12, 2022
1 parent 93e3c75 commit 9b67fb8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ type Help struct {

// Matches checks if the given KeyMsg matches the given bindings.
func Matches(k tea.KeyMsg, b ...Binding) bool {
keys := k.String()
for _, binding := range b {
for _, v := range binding.keys {
if k.String() == v && binding.Enabled() {
if keys == v && binding.Enabled() {
return true
}
}
Expand Down

0 comments on commit 9b67fb8

Please sign in to comment.