aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf/FieldCodec.cs
diff options
context:
space:
mode:
authorGravatar Jon Skeet <jonskeet@google.com>2017-10-25 16:03:23 +0100
committerGravatar Jon Skeet <skeet@pobox.com>2017-12-09 09:49:24 +0000
commitf3e9a65d758d47633a161e526b35dea22bac9a5c (patch)
treea1733195e76c088c2f83093910c92e4d5609d275 /csharp/src/Google.Protobuf/FieldCodec.cs
parent618f06fc9cd7fd872de8977dfe40294cadb4af21 (diff)
Compare floating point values bitwise in C#
This is the manual code part of the Google.Protobuf library, and tests. Some tests will fail until codegen is changed and rerun.
Diffstat (limited to 'csharp/src/Google.Protobuf/FieldCodec.cs')
-rw-r--r--csharp/src/Google.Protobuf/FieldCodec.cs4
1 files changed, 3 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf/FieldCodec.cs b/csharp/src/Google.Protobuf/FieldCodec.cs
index c28b47e1..a11f2420 100644
--- a/csharp/src/Google.Protobuf/FieldCodec.cs
+++ b/csharp/src/Google.Protobuf/FieldCodec.cs
@@ -30,6 +30,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
+using Google.Protobuf.Collections;
using Google.Protobuf.Compatibility;
using Google.Protobuf.WellKnownTypes;
using System;
@@ -346,6 +347,7 @@ namespace Google.Protobuf
/// </remarks>
public sealed class FieldCodec<T>
{
+ private static readonly EqualityComparer<T> EqualityComparer = ProtobufEqualityComparers.GetEqualityComparer<T>();
private static readonly T DefaultDefault;
// Only non-nullable value types support packing. This is the simplest way of detecting that.
private static readonly bool TypeSupportsPacking = default(T) != null;
@@ -469,6 +471,6 @@ namespace Google.Protobuf
/// </summary>
public int CalculateSizeWithTag(T value) => IsDefault(value) ? 0 : ValueSizeCalculator(value) + tagSize;
- private bool IsDefault(T value) => EqualityComparer<T>.Default.Equals(value, DefaultValue);
+ private bool IsDefault(T value) => EqualityComparer.Equals(value, DefaultValue);
}
}