refactor(list): reduce allocations in filterItems (#396)

As the number of items in `targets` is known, use `make` with the
expected size instead of appending, which requires more allocations as
the `targets` slice grows.
This commit is contained in:
naglis
2023-07-25 14:06:33 -07:00
committed by GitHub
parent 0bdcc628fb
commit 95d7be54d9
+3 -3
View File
@@ -1218,11 +1218,11 @@ func filterItems(m Model) tea.Cmd {
return FilterMatchesMsg(m.itemsAsFilterItems()) // return nothing
}
targets := []string{}
items := m.items
targets := make([]string, len(items))
for _, t := range items {
targets = append(targets, t.FilterValue())
for i, t := range items {
targets[i] = t.FilterValue()
}
filterMatches := []filteredItem{}