From 84f30966654d8a6ba27f24040e8a48fd16fe0c37 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Fri, 5 Aug 2022 12:22:09 -0400 Subject: [PATCH] perf: improve filter fuzzy by pre-allocating slice --- filter/filter.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/filter/filter.go b/filter/filter.go index b5a8953..79e4dec 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -135,10 +135,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func matchAll(options []string) []fuzzy.Match { - //nolint:prealloc - var matches []fuzzy.Match - for _, option := range options { - matches = append(matches, fuzzy.Match{Str: option}) + var matches = make([]fuzzy.Match, len(options)) + for i, option := range options { + matches[i] = fuzzy.Match{Str: option} } return matches }