@@ -15,6 +15,13 @@ import (
1515 "github.com/sahilm/fuzzy"
1616)
1717
18+var (
19+ // Pre-compiled regex for checking if a string contains alphabetic characters.
20+ alphaRegex = regexp.MustCompile(`[a-zA-Z]`)
21+ // Pre-compiled regex for checking if a string is alphanumeric.
22+ alphanumericRegex = regexp.MustCompile(`^[a-zA-Z0-9]*$`)
23+)
24+
1825type FilterableItem interface {
1926 Item
2027 FilterValue() string
@@ -165,8 +172,6 @@ func (f *filterableList[T]) View() string {
165172
166173// removes bindings that are used for search
167174func (f *filterableList[T]) updateKeyMaps() {
168− alphanumeric := regexp.MustCompile("^[a-zA-Z0-9]*$")
169−
170175 removeLettersAndNumbers := func(bindings []string) []string {
171176 var keep []string
172177 for _, b := range bindings {
@@ -177,7 +182,7 @@ func (f *filterableList[T]) updateKeyMaps() {
177182 if b == " " {
178183 continue
179184 }
180− m := alphanumeric.MatchString(b)
185+ m := alphanumericRegex.MatchString(b)
181186 if !m {
182187 keep = append(keep, b)
183188 }