/// <summary> /// Returns a hash code for this instance. /// </summary> /// <param name="obj">The object.</param> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode(byte[] obj) { // Null if (obj == null) { return(FnvHashCode.FnvNull); } // Empty if (obj.Length == 0) { return(FnvHashCode.FnvEmpty); } // Calculate on full length var span = obj.AsSpan(); // Calculate on prefix if (HashCodeFidelity > 0 && obj.Length > HashCodeFidelity) { span = span.Slice(0, HashCodeFidelity); } var hc = FnvHashCode.Combine(span); return(hc); }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <param name="obj">The object.</param> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode(ReadOnlyMemory <byte> obj) { // Empty if (obj.Length == 0) { return(FnvHashCode.FnvEmpty); } // Calculate on full length var span = obj.Span; // Calculate on prefix if (HashCodeFidelity > 0 && obj.Length > HashCodeFidelity) { span = span.Slice(0, HashCodeFidelity); } var hc = FnvHashCode.Combine(span); return(hc); }