/// <summary> /// Get hash code for sub string /// </summary> public static int GetHashCode(string s, int index, int length) { if (s == null) { throw new ArgumentNullException(nameof(s)); } if (index < 0) { throw new ArgumentOutOfRangeException(nameof(index)); } if (((uint)index + (uint)length) > s.Length) { throw new ArgumentOutOfRangeException(nameof(length)); } unsafe { fixed(char *p = s) { return(FastStringComparer.FastGetHash(p + index, length)); } } }
/// <summary> /// Get Hash code for full string /// </summary> public static int GetHashCode(string s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } unsafe { fixed(char *p = s) { return(FastStringComparer.FastGetHash(p, s.Length)); } } }
/// <summary> /// Get Hash code for full byte array, return true for all ASCII /// </summary> public static int GetHashCode(byte[] s, out bool isAscii) { if (s == null) { throw new ArgumentNullException(nameof(s)); } unsafe { fixed(byte *p = s) { return(FastStringComparer.FastGetHash(p, s.Length, out isAscii)); } } }
public static bool Equals(string x, string y) { #if WIN64 if (object.ReferenceEquals(x, y)) { return(true); } if ((x == null) || (y == null)) { return(false); } if (x.Length != y.Length) { return(false); } return(FastStringComparer.EqualsHelp64(x, y)); #else return(string.Equals(x, y)); #endif }
int IEqualityComparer <string> .GetHashCode(string obj) { return(FastStringComparer.GetHashCode(obj)); }
bool IEqualityComparer <string> .Equals(string x, string y) { return(FastStringComparer.Equals(x, y)); }