Skip to content

Commit

Permalink
don't iterate over data so much
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Feb 22, 2020
1 parent dd574d2 commit 9f1f341
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Wave.elm
Expand Up @@ -279,10 +279,17 @@ propagateInDirection source sourceCell direction ( Wave wave, todo ) =
|> Maybe.withDefault Set.empty

Open remaining_ ->
remaining_
|> Set.toList
|> List.filterMap (\value -> Dict.get ( value, direction ) wave.rules)
|> List.foldl Set.union Set.empty
Set.foldl
(\value acc ->
case Dict.get ( value, direction ) wave.rules of
Just rules ->
Set.union acc rules

Nothing ->
acc
)
Set.empty
remaining_

reduced =
Set.intersect remaining possibleInDirection
Expand Down

0 comments on commit 9f1f341

Please sign in to comment.