Skip to content

Commit

Permalink
Avoid creating redundant List with all menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaime Terreu committed Jan 19, 2025
1 parent d2bf008 commit 1141d87
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Select.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2324,16 +2324,15 @@ viewVirtual (Config config) =
adjustedItem =
applyVirtualConfigMenuItem idx virtualConfig.height mi
in
Tuple.mapBoth ((::) adjustedItem) (Array.push adjustedItem) acc
Array.push adjustedItem acc
)
( [], Array.empty )
Array.empty
filteredMenuItems
|> sliceItems
|> Tuple.first
|> setVirtualMenuItems config.menuItems

sliceItems ( _, cache ) =
( Array.slice startIndex (stopIndex + 1) cache |> Array.toList, cache )
sliceItems cache =
Array.slice startIndex (stopIndex + 1) cache |> Array.toList

startIndexForOffset : Int
startIndexForOffset =
Expand Down

0 comments on commit 1141d87

Please sign in to comment.