From 267c426bf31c959882297348676747b7f58d5dbf Mon Sep 17 00:00:00 2001 From: Dan Andrei Singeorzan Date: Mon, 17 Jun 2024 18:04:59 +0300 Subject: [PATCH 1/2] process locations jit --- .../Expressions/CompiledExpressionInvoker.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs b/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs index ee2d6166..6d15ab0f 100644 --- a/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs +++ b/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs @@ -22,6 +22,7 @@ public class CompiledExpressionInvoker private readonly IList _locationReferences; private CodeActivityMetadata _metadata; private CodeActivityPublicEnvironmentAccessor _accessor; + private bool _locationsInitialized; public CompiledExpressionInvoker(ITextExpression expression, bool isReference, CodeActivityMetadata metadata) { @@ -40,7 +41,10 @@ public CompiledExpressionInvoker(ITextExpression expression, bool isReference, C _metadataRoot = metadata.Environment.Root; - ProcessLocationReferences(); + if (!metadata.Environment.IsValidating) + { + ProcessLocationReferences(); + } } public object InvokeExpression(ActivityContext activityContext) @@ -50,6 +54,11 @@ public object InvokeExpression(ActivityContext activityContext) throw FxTrace.Exception.ArgumentNull(nameof(activityContext)); } + if (!_locationsInitialized) + { + ProcessLocationReferences(); + } + if (_compiledRoot == null || _expressionId < 0) { if (!TryGetCompiledExpressionRoot(_expressionActivity, _metadataRoot, out _compiledRoot) || @@ -154,6 +163,11 @@ internal static bool TryGetCompiledExpressionRoot(Activity target, bool forImple internal Expression GetExpressionTree() { + if (!_locationsInitialized) + { + ProcessLocationReferences(); + } + if (_compiledRoot == null || _expressionId < 0) { if (!TryGetCompiledExpressionRootAtDesignTime(_expressionActivity, _metadataRoot, out _compiledRoot, out _expressionId)) @@ -244,6 +258,8 @@ private void ProcessLocationReferences() CreateRequiredArguments(requiredLocationNames); } } + + _locationsInitialized = true; } private bool TryGetCompiledExpressionRootAtDesignTime(Activity expression, Activity target, out ICompiledExpressionRoot compiledExpressionRoot, out int exprId) From 7e85d1f5c16ae52354a8470b9e9e92eb79a0c6fd Mon Sep 17 00:00:00 2001 From: Dan Andrei Singeorzan Date: Tue, 18 Jun 2024 16:30:38 +0300 Subject: [PATCH 2/2] set flat at start of method --- .../Expressions/CompiledExpressionInvoker.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs b/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs index 6d15ab0f..dd5c90c3 100644 --- a/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs +++ b/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs @@ -212,6 +212,8 @@ private bool CanExecuteExpression(ICompiledExpressionRoot compiledExpressionRoot private void ProcessLocationReferences() { + _locationsInitialized = true; + Stack environments = new(); // // Build list of location by enumerating environments @@ -258,8 +260,6 @@ private void ProcessLocationReferences() CreateRequiredArguments(requiredLocationNames); } } - - _locationsInitialized = true; } private bool TryGetCompiledExpressionRootAtDesignTime(Activity expression, Activity target, out ICompiledExpressionRoot compiledExpressionRoot, out int exprId)