perf: avoid recomputing the key representation in key.Matches

This commit is contained in:
kena 2022-08-12 22:07:31 +02:00 committed by GitHub
parent 93e3c756c4
commit 9b67fb8724
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}
}