aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffers/ByteString.cs
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2015-07-17 07:29:50 +0100
committerJon Skeet <skeet@pobox.com>2015-07-17 07:29:50 +0100
commit0f442a7533b1d06ce0092b28f10af481b99e1369 (patch)
tree4f9cb3ecb2d8ab4f9c138a06d645a3cc3dcdeef3 /csharp/src/ProtocolBuffers/ByteString.cs
parentfa544f4835623be66d73e1d984121ab4a92e1650 (diff)
parent34878cb14eba4578d1d67d2dc93250729d492774 (diff)
downloadprotobuf-0f442a7533b1d06ce0092b28f10af481b99e1369.tar.gz
protobuf-0f442a7533b1d06ce0092b28f10af481b99e1369.tar.bz2
protobuf-0f442a7533b1d06ce0092b28f10af481b99e1369.zip
Merge pull request #611 from jskeet/csharp-wrappers
C# wrapper types
Diffstat (limited to 'csharp/src/ProtocolBuffers/ByteString.cs')
-rw-r--r--csharp/src/ProtocolBuffers/ByteString.cs35
1 files changed, 15 insertions, 20 deletions
diff --git a/csharp/src/ProtocolBuffers/ByteString.cs b/csharp/src/ProtocolBuffers/ByteString.cs
index 738f020e..329f47f6 100644
--- a/csharp/src/ProtocolBuffers/ByteString.cs
+++ b/csharp/src/ProtocolBuffers/ByteString.cs
@@ -212,11 +212,22 @@ namespace Google.Protobuf
{
return true;
}
- if (ReferenceEquals(lhs, null))
+ if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null))
{
return false;
}
- return lhs.Equals(rhs);
+ if (lhs.bytes.Length != rhs.bytes.Length)
+ {
+ return false;
+ }
+ for (int i = 0; i < lhs.Length; i++)
+ {
+ if (rhs.bytes[i] != lhs.bytes[i])
+ {
+ return false;
+ }
+ }
+ return true;
}
public static bool operator !=(ByteString lhs, ByteString rhs)
@@ -228,12 +239,7 @@ namespace Google.Protobuf
public override bool Equals(object obj)
{
- ByteString other = obj as ByteString;
- if (obj == null)
- {
- return false;
- }
- return Equals(other);
+ return this == (obj as ByteString);
}
public override int GetHashCode()
@@ -248,18 +254,7 @@ namespace Google.Protobuf
public bool Equals(ByteString other)
{
- if (other.bytes.Length != bytes.Length)
- {
- return false;
- }
- for (int i = 0; i < bytes.Length; i++)
- {
- if (other.bytes[i] != bytes[i])
- {
- return false;
- }
- }
- return true;
+ return this == other;
}
/// <summary>