Skip to content

Commit

Permalink
Improve Expression.Lambda<TDelegate> performance (dotnet#32768)
Browse files Browse the repository at this point in the history
Unnecessary cache call in Expression.Lambda<TDelegate>
(with reflection in worst scenario) has been removed.

Fix dotnet#32767
  • Loading branch information
Vladimir Chirikov authored Feb 25, 2020
1 parent ce23ff9 commit 634b348
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,11 @@ public static Expression<TDelegate> Lambda<TDelegate>(Expression body, string? n
{
ReadOnlyCollection<ParameterExpression> parameterList = parameters.ToReadOnly();
ValidateLambdaArgs(typeof(TDelegate), ref body, parameterList, nameof(TDelegate));
return (Expression<TDelegate>)CreateLambda(typeof(TDelegate), body, name, tailCall, parameterList);
#if FEATURE_COMPILE
return Expression<TDelegate>.Create(body, name, tailCall, parameterList);
#else
return ExpressionCreator<TDelegate>.CreateExpressionFunc(body, name, tailCall, parameterList);
#endif
}

/// <summary>
Expand Down

0 comments on commit 634b348

Please sign in to comment.