Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: third_party/protobuf/csharp/src/Google.Protobuf/ByteString.cs

Issue 2599263002: third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Address comments Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #region Copyright notice and license 1 #region Copyright notice and license
2 // Protocol Buffers - Google's data interchange format 2 // Protocol Buffers - Google's data interchange format
3 // Copyright 2008 Google Inc. All rights reserved. 3 // Copyright 2008 Google Inc. All rights reserved.
4 // https://developers.google.com/protocol-buffers/ 4 // https://developers.google.com/protocol-buffers/
5 // 5 //
6 // Redistribution and use in source and binary forms, with or without 6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are 7 // modification, are permitted provided that the following conditions are
8 // met: 8 // met:
9 // 9 //
10 // * Redistributions of source code must retain the above copyright 10 // * Redistributions of source code must retain the above copyright
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 /// <summary> 296 /// <summary>
297 /// Returns a hash code for this object. Two equal byte strings 297 /// Returns a hash code for this object. Two equal byte strings
298 /// will return the same hash code. 298 /// will return the same hash code.
299 /// </summary> 299 /// </summary>
300 /// <returns>A hash code for this object.</returns> 300 /// <returns>A hash code for this object.</returns>
301 public override int GetHashCode() 301 public override int GetHashCode()
302 { 302 {
303 int ret = 23; 303 int ret = 23;
304 foreach (byte b in bytes) 304 foreach (byte b in bytes)
305 { 305 {
306 ret = (ret << 8) | b; 306 ret = (ret * 31) + b;
307 } 307 }
308 return ret; 308 return ret;
309 } 309 }
310 310
311 /// <summary> 311 /// <summary>
312 /// Compares this byte string with another. 312 /// Compares this byte string with another.
313 /// </summary> 313 /// </summary>
314 /// <param name="other">The <see cref="ByteString"/> to compare this wit h.</param> 314 /// <param name="other">The <see cref="ByteString"/> to compare this wit h.</param>
315 /// <returns><c>true</c> if <paramref name="other"/> refers to an equal byte string; <c>false</c> otherwise.</returns> 315 /// <returns><c>true</c> if <paramref name="other"/> refers to an equal byte string; <c>false</c> otherwise.</returns>
316 public bool Equals(ByteString other) 316 public bool Equals(ByteString other)
(...skipping 19 matching lines...) Expand all
336 336
337 /// <summary> 337 /// <summary>
338 /// Writes the entire byte array to the provided stream 338 /// Writes the entire byte array to the provided stream
339 /// </summary> 339 /// </summary>
340 public void WriteTo(Stream outputStream) 340 public void WriteTo(Stream outputStream)
341 { 341 {
342 outputStream.Write(bytes, 0, bytes.Length); 342 outputStream.Write(bytes, 0, bytes.Length);
343 } 343 }
344 } 344 }
345 } 345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698