-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize cachedExpressionCompiler by changing cache key to remove Exp…
…ression.Lambda() calls
- Loading branch information
Showing
4 changed files
with
61 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
|
||
namespace MiaPlaza.ExpressionUtils { | ||
|
||
/// <summary> | ||
/// Sometimes we don't have actual <see cref="LambdaExpression"/> object, but instead <see cref="LambdaExpression.Body"/> and <see cref="LambdaExpression.Parameters"/> that represent lambda. | ||
/// We could call <see cref="Expression.Lambda(Expression, ParameterExpression[])"/> to get it, but such calls can be expensive due to locking that is used inside. | ||
/// So this object plays a role of a container that holds the data that is needed to create lambda expression. | ||
/// </summary> | ||
/// <remarks> | ||
/// Before <see cref="LambdaExpression"/> objects were used to fullfill that role. This was added to replace those. | ||
/// </remarks> | ||
public class LambdaParts { | ||
public Expression Body { get; set; } | ||
public IReadOnlyCollection<ParameterExpression> Parameters { get; set; } | ||
|
||
public static implicit operator LambdaParts(LambdaExpression lambda) | ||
=> lambda is null ? null : new LambdaParts { Body = lambda.Body, Parameters = lambda.Parameters }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters