Skip to content

Commit

Permalink
Reduce compilation expenses in emitClosureExpressions
Browse files Browse the repository at this point in the history
Refactor to avoid duplicate processing in the 'emitClosureExpressions' function we use to compile the set of declarations in an Elm module.
  • Loading branch information
Viir committed Jul 14, 2023
1 parent 6c24b73 commit 921c099
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2295,20 +2295,19 @@ emitClosureExpression :
-> List ( String, Expression )
-> Expression
-> Result String Pine.Expression
emitClosureExpression stackBefore environmentDeclarations expressionInClosure =
emitClosureExpression stackBefore environmentDeclarations =
emitExpressionInDeclarationBlock
stackBefore
environmentDeclarations
expressionInClosure
|> Result.map .expr
>> Result.map .expr


emitExpressionInDeclarationBlock :
EmitStack
-> List ( String, Expression )
-> Expression
-> Result String { expr : Pine.Expression, closureArgumentPine : Maybe Pine.Expression }
emitExpressionInDeclarationBlock stack originalEnvironmentDeclarations originalMainExpression =
emitExpressionInDeclarationBlock stack originalEnvironmentDeclarations =
let
environmentDeclarations =
originalEnvironmentDeclarations
Expand All @@ -2319,17 +2318,19 @@ emitExpressionInDeclarationBlock stack originalEnvironmentDeclarations originalM
originalEnvironmentDeclarations
)
)

mainExpression =
inlineApplicationsOfEnvironmentDeclarations
stack
environmentDeclarations
originalMainExpression
in
emitExpressionInDeclarationBlockLessInline
stack
environmentDeclarations
mainExpression
\originalMainExpression ->
let
mainExpression =
inlineApplicationsOfEnvironmentDeclarations
stack
environmentDeclarations
originalMainExpression
in
emitExpressionInDeclarationBlockLessInline
stack
environmentDeclarations
mainExpression


emitExpressionInDeclarationBlockLessInline :
Expand Down

0 comments on commit 921c099

Please sign in to comment.