Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial fix to #35053 - Is EF9 slower than EF8? #35128

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/EFCore/ChangeTracking/ValueComparer`.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,18 @@ public override LambdaExpression ObjectEqualsExpression
var left = Parameter(typeof(object), "left");
var right = Parameter(typeof(object), "right");

var remappedEquals = ReplacingExpressionVisitor.Replace(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, although I wonder if we are sometimes doing work (casts and comparisons) here that we don't need to do in some cases. I will add a note to #29909, which is about perf improvements in this area.

EqualsExpression.Parameters.ToList(),
[Convert(left, typeof(T)), Convert(right, typeof(T))],
EqualsExpression.Body);

_objectEqualsExpression = Lambda<Func<object?, object?, bool>>(
Condition(
Equal(left, Constant(null)),
Equal(right, Constant(null)),
AndAlso(
NotEqual(right, Constant(null)),
Invoke(
EqualsExpression,
Convert(left, typeof(T)),
Convert(right, typeof(T))))),
remappedEquals)),
left,
right);
}
Expand Down