Compute visitors only once for a given input

This commit is contained in:
Jeroen Engels 2017-01-08 10:58:45 +01:00
parent 3c27a18207
commit a491c97059
2 changed files with 12 additions and 7 deletions

View File

@ -93,12 +93,9 @@ statementToVisitors node =
[] []
lint : List Statement -> LintRule context -> List Error lintWithVisitors : List (Visitor context) -> LintRule context -> List Error
lint statements rule = lintWithVisitors visitors rule =
let let
visitors =
List.concatMap statementToVisitors statements
( errors, _ ) = ( errors, _ ) =
List.foldl List.foldl
(\visitor ( errors, ctx ) -> (\visitor ( errors, ctx ) ->
@ -112,3 +109,8 @@ lint statements rule =
visitors visitors
in in
errors errors
lint : List Statement -> LintRule context -> List Error
lint statements =
lintWithVisitors (List.concatMap statementToVisitors statements)

View File

@ -100,10 +100,13 @@ lint ast =
|> Result.map (\( _, _, statements ) -> statements) |> Result.map (\( _, _, statements ) -> statements)
|> Result.withDefault [] |> Result.withDefault []
lint =
Lint.lint statements
errors = errors =
List.concat List.concat
[ Lint.lint statements FindNoAnnotatedFunction.rule [ lint FindNoAnnotatedFunction.rule
, Lint.lint statements NoDebug.rule , lint NoDebug.rule
] ]
in in
div [] (List.map (\x -> p [] [ text x ]) errors) div [] (List.map (\x -> p [] [ text x ]) errors)