From 79c4766cf69206fc82caddce90c38845c284a638 Mon Sep 17 00:00:00 2001 From: "Angelo (Haibo) Wang" Date: Sun, 2 Jul 2023 18:37:48 +0800 Subject: [PATCH] Avoid unnecessary location argument for VB compiling For CompiledExpressionInvoker.ProcessLocationReferences, the microsoft reference source is not always create location argument, but only when `RequiresCompilation` is true, which is for C#. This helps for performance a lot when there are a lot of expressions to compile. --- .../Expressions/CompiledExpressionInvoker.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs b/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs index ee2d61666..f97f44cbd 100644 --- a/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs +++ b/src/UiPath.Workflow.Runtime/Expressions/CompiledExpressionInvoker.cs @@ -209,11 +209,16 @@ private void ProcessLocationReferences() current = current.Parent; } + bool requiresCompilation = _textExpression.Language != "VB"; + foreach (LocationReferenceEnvironment environment in environments) { foreach (LocationReference reference in environment.GetLocationReferences()) { - _accessor.CreateLocationArgument(reference, false); + if (requiresCompilation) + { + _accessor.CreateLocationArgument(reference, false); + } _locationReferences.Add(new InlinedLocationReference(reference, _metadata.CurrentActivity)); } } @@ -238,7 +243,7 @@ private void ProcessLocationReferences() // for locations that are referenced in the expressions. To maintain // consistency the we call the CreateRequiredArguments method seperately to // generates auto arguments only for locations that are referenced. - if (_textExpression.Language == "VB") + if (!requiresCompilation) { IList requiredLocationNames = _compiledRoot.GetRequiredLocations(_expressionId); CreateRequiredArguments(requiredLocationNames);