Commit e3aff478 authored by Ayende Rahien's avatar Ayende Rahien

Making ByteString.bytes internal, to allow faster access to the raw bytes.

Fixing ByteString.GetHashCode to create good hash code.
parent d3f2d098
...@@ -46,7 +46,7 @@ namespace Google.ProtocolBuffers { ...@@ -46,7 +46,7 @@ namespace Google.ProtocolBuffers {
private static readonly ByteString empty = new ByteString(new byte[0]); private static readonly ByteString empty = new ByteString(new byte[0]);
private readonly byte[] bytes; internal readonly byte[] bytes;
/// <summary> /// <summary>
/// Constructs a new ByteString from the given byte array. The array is /// Constructs a new ByteString from the given byte array. The array is
...@@ -154,10 +154,11 @@ namespace Google.ProtocolBuffers { ...@@ -154,10 +154,11 @@ namespace Google.ProtocolBuffers {
} }
public override int GetHashCode() { public override int GetHashCode() {
int ret = 23; int ret = 23;
foreach (byte b in bytes) { for (int i = 0; i < bytes.Length; i++)
ret = (ret << 8) | b; {
} ret = (ret * 23) ^ bytes[i];
}
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment