Skip to content

Commit

Permalink
reduce lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Feb 22, 2020
1 parent d46f8f5 commit dd574d2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Wave.elm
Expand Up @@ -163,16 +163,17 @@ collapse seed coords (Wave wave) =
Just (Open remaining) ->
let
generator =
wave.weights
|> Dict.toList
|> List.filterMap
(\( k, weight ) ->
if Set.member k remaining then
Just ( toFloat weight, k )

else
Nothing
remaining
|> Set.foldl
(\current acc ->
case Dict.get current wave.weights of
Just weight ->
( toFloat weight, current ) :: acc

Nothing ->
acc
)
[]
|> (\weights ->
case weights of
[] ->
Expand Down

0 comments on commit dd574d2

Please sign in to comment.