Skip to content

Commit e85d911

Browse files
author
maximv
committed
refactoring
1 parent 2566480 commit e85d911

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

src/FastExpressionCompiler/FastExpressionCompiler.cs

+10-19
Original file line numberDiff line numberDiff line change
@@ -601,17 +601,12 @@ public object[] GetArrayOfConstantsAndNestedLambdas()
601601
for (var i = 0; i < nestedLambdas.Length; i++)
602602
{
603603
var nestedLambda = nestedLambdas[i];
604-
if (nestedLambda.ClosureInfo.NonPassedParameters.Length == 0)
604+
if (nestedLambda.ClosureInfo.NonPassedParameters.Length == 0 ||
605+
nestedLambda.ClosureInfo.ContainsConstantsOrNestedLambdas() == false)
605606
nestedLambdaItems[i] = nestedLambda.Lambda;
606607
else
607-
{
608-
var nestedConstantsAndNestedLambdas = nestedLambda.ClosureInfo.GetArrayOfConstantsAndNestedLambdas();
609-
if (nestedConstantsAndNestedLambdas != null)
610-
nestedLambdaItems[i] = new NestedLambdaWithConstantsAndNestedLambdas(nestedLambda.Lambda,
611-
nestedConstantsAndNestedLambdas);
612-
else
613-
nestedLambdaItems[i] = nestedLambda.Lambda;
614-
}
608+
nestedLambdaItems[i] = new NestedLambdaWithConstantsAndNestedLambdas(
609+
nestedLambda.Lambda, nestedLambda.ClosureInfo.GetArrayOfConstantsAndNestedLambdas());
615610
}
616611

617612
return nestedLambdaItems;
@@ -643,17 +638,12 @@ public object[] GetArrayOfConstantsAndNestedLambdas()
643638
for (var i = 0; i < nestedLambdas.Length; i++)
644639
{
645640
var nestedLambda = nestedLambdas[i];
646-
if (nestedLambda.ClosureInfo.NonPassedParameters.Length == 0)
641+
if (nestedLambda.ClosureInfo.NonPassedParameters.Length == 0 ||
642+
nestedLambda.ClosureInfo.ContainsConstantsOrNestedLambdas() == false)
647643
closureItems[constCount + i] = nestedLambda.Lambda;
648644
else
649-
{
650-
var nestedConstantsAndNestedLambdas = nestedLambda.ClosureInfo.GetArrayOfConstantsAndNestedLambdas();
651-
if (nestedConstantsAndNestedLambdas != null)
652-
closureItems[constCount + i] = new NestedLambdaWithConstantsAndNestedLambdas(
653-
nestedLambda.Lambda, nestedConstantsAndNestedLambdas);
654-
else
655-
closureItems[constCount + i] = nestedLambda.Lambda;
656-
}
645+
closureItems[constCount + i] = new NestedLambdaWithConstantsAndNestedLambdas(
646+
nestedLambda.Lambda, nestedLambda.ClosureInfo.GetArrayOfConstantsAndNestedLambdas());
657647
}
658648

659649
return closureItems;
@@ -1365,7 +1355,8 @@ private static bool TryCompileNestedLambda(ref ClosureInfo outerClosureInfo, int
13651355

13661356
var il = method.GetILGenerator();
13671357

1368-
if ((nestedClosureInfo.Status & ClosureStatus.HasClosure) != 0 && nestedClosureInfo.ContainsConstantsOrNestedLambdas())
1358+
if ((nestedClosureInfo.Status & ClosureStatus.HasClosure) != 0 &&
1359+
nestedClosureInfo.ContainsConstantsOrNestedLambdas())
13691360
EmittingVisitor.EmitLoadConstantsAndNestedLambdasIntoVars(il, ref nestedClosureInfo);
13701361

13711362
var parentFlags = nestedReturnType == typeof(void) ? ParentFlags.IgnoreResult : ParentFlags.Empty;

0 commit comments

Comments
 (0)