From: Vladimir Chirikov Date: Tue, 25 Feb 2020 21:22:28 +0000 (+0300) Subject: Improve Expression.Lambda performance (#32768) X-Git-Tag: submit/tizen/20210909.063632~9504 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=634b3484262cc4bc288c605cb1e6374cc76655a0;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Improve Expression.Lambda performance (#32768) Unnecessary cache call in Expression.Lambda (with reflection in worst scenario) has been removed. Fix #32767 --- diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs index 0d60e32..0e1ead7 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs @@ -687,7 +687,11 @@ namespace System.Linq.Expressions { ReadOnlyCollection parameterList = parameters.ToReadOnly(); ValidateLambdaArgs(typeof(TDelegate), ref body, parameterList, nameof(TDelegate)); - return (Expression)CreateLambda(typeof(TDelegate), body, name, tailCall, parameterList); +#if FEATURE_COMPILE + return Expression.Create(body, name, tailCall, parameterList); +#else + return ExpressionCreator.CreateExpressionFunc(body, name, tailCall, parameterList); +#endif } ///