From 9b67fb87249e4ae2c3bff6bfe1b14651a943c083 Mon Sep 17 00:00:00 2001 From: kena Date: Fri, 12 Aug 2022 22:07:31 +0200 Subject: [PATCH] perf: avoid recomputing the key representation in `key.Matches` --- key/key.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/key/key.go b/key/key.go index fdc7800..ac08194 100644 --- a/key/key.go +++ b/key/key.go @@ -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 } }