mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +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
|
return FilterMatchesMsg(m.itemsAsFilterItems()) // return nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
targets := []string{}
|
|
||||||
items := m.items
|
items := m.items
|
||||||
|
targets := make([]string, len(items))
|
||||||
|
|
||||||
for _, t := range items {
|
for i, t := range items {
|
||||||
targets = append(targets, t.FilterValue())
|
targets[i] = t.FilterValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
filterMatches := []filteredItem{}
|
filterMatches := []filteredItem{}
|
||||||
|
|||||||
Reference in New Issue
Block a user