Пример #1
0
        /// <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));
                }
            }
        }
Пример #2
0
        /// <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));
                }
            }
        }
Пример #3
0
        /// <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));
                }
            }
        }
Пример #4
0
        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
        }
Пример #5
0
 int IEqualityComparer <string> .GetHashCode(string obj)
 {
     return(FastStringComparer.GetHashCode(obj));
 }
Пример #6
0
 bool IEqualityComparer <string> .Equals(string x, string y)
 {
     return(FastStringComparer.Equals(x, y));
 }