Skip to content

Commit 950cd99

Browse files
asignergithub-actions[bot]
authored andcommitted
perf: revert rootContext to val for performance optimization
Reverted rootContext back from a method to an immutable val in FeelEngine to avoid repeated context creation on every evaluation invocation. The mutable failureCollector is initialized on demand when merging the context. Partly reverts 851a743 Reviewed-by: saig0 (cherry picked from commit 93dab53)
1 parent ab62e71 commit 950cd99

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/scala/org/camunda/feel/FeelEngine.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class FeelEngine(
133133
s"configuration: $configuration]"
134134
)
135135

136-
private def rootContext(): EvalContext = EvalContext.create(
136+
private val rootContext: EvalContext = EvalContext.create(
137137
valueMapper = valueMapper,
138138
functionProvider = FunctionProvider.CompositeFunctionProvider(
139139
List(
@@ -330,7 +330,8 @@ class FeelEngine(
330330
@deprecated def evaluate(expression: ParsedExpression, context: Context): EvaluationResult =
331331
Try {
332332
validate(expression) match {
333-
case Right(_) => eval(expression, rootContext().merge(context))
333+
case Right(_) =>
334+
eval(expression, EvalContext.empty(valueMapper).merge(rootContext).merge(context))
334335
case Left(failure) => FailedEvaluationResult(failure = failure)
335336
}
336337
}.recover(failure =>

0 commit comments

Comments
 (0)