mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 04:36:07 +00:00
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:
+3
-3
@@ -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{}
|
||||
|
||||
Reference in New Issue
Block a user