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

No boxing for structs #22030

Merged
merged 7 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
22 changes: 18 additions & 4 deletions src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected CompiledQueryCacheKey GenerateCacheKeyCore([NotNull] Expression query,
/// not used in application code.
/// </para>
/// </summary>
protected readonly struct CompiledQueryCacheKey
protected readonly struct CompiledQueryCacheKey : IEquatable<CompiledQueryCacheKey>
roji marked this conversation as resolved.
Show resolved Hide resolved
{
private readonly Expression _query;
private readonly IModel _model;
Expand Down Expand Up @@ -121,10 +121,24 @@ public override bool Equals(object obj)

var other = (CompiledQueryCacheKey)obj;

return Equals(other);
}

/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
/// </summary>
/// <param name="other">
/// An object to compare with this object.
/// </param>
/// <returns>
/// <see langword="true" /> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <see langword="false" />.
/// </returns>
public bool Equals(CompiledQueryCacheKey other)
{
return ReferenceEquals(_model, other._model)
&& _queryTrackingBehavior == other._queryTrackingBehavior
&& _async == other._async
&& ExpressionEqualityComparer.Instance.Equals(_query, other._query);
&& _queryTrackingBehavior == other._queryTrackingBehavior
roji marked this conversation as resolved.
Show resolved Hide resolved
&& _async == other._async
&& ExpressionEqualityComparer.Instance.Equals(_query, other._query);
}

/// <summary>
Expand Down
13 changes: 11 additions & 2 deletions src/EFCore/Storage/ValueBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Microsoft.EntityFrameworkCore.Storage
/// not used in application code.
/// </para>
/// </summary>
public readonly struct ValueBuffer
public readonly struct ValueBuffer : IEquatable<ValueBuffer>
{
/// <summary>
/// A buffer with no values in it.
Expand Down Expand Up @@ -79,7 +79,16 @@ public override bool Equals(object obj)
&& obj is ValueBuffer buffer
&& Equals(buffer);

private bool Equals(ValueBuffer other)
/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
/// </summary>
/// <param name="other">
/// An object to compare with this object.
/// </param>
/// <returns>
/// <see langword="true" /> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <see langword="false" />.
/// </returns>
public bool Equals(ValueBuffer other)
{
if (_values.Length != other._values.Length)
{
Expand Down