Example #1
0
        public override int GetHashCode()
        {
            ulong seed = Marvin.DefaultSeed;

            // Multiplication below will not overflow since going from positive Int32 to UInt32.
            return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref _firstChar), (uint)_stringLength * 2 /* in bytes, not chars */, (uint)seed, (uint)(seed >> 32)));
        }
Example #2
0
        public static int GetHashCode(ReadOnlySpan <char> value)
        {
            ulong seed = Marvin.DefaultSeed;

            // Multiplication below will not overflow since going from positive Int32 to UInt32.
            return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref MemoryMarshal.GetReference(value)), (uint)value.Length * 2 /* in bytes, not chars */, (uint)seed, (uint)(seed >> 32)));
        }
        // Gets a hash code for this string.  If strings A and B are such that A.Equals(B), then
        // they will return the same hash code.
        public override int GetHashCode()
        {
#if MONO
            return(LegacyStringGetHashCode());
#else
            return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref _firstChar), _stringLength * 2, Marvin.DefaultSeed));
#endif
        }
Example #4
0
        /// <summary>
        /// Returns a hash code using a <see cref="StringComparison.Ordinal"/> comparison.
        /// </summary>
        public override int GetHashCode()
        {
            // TODO_UTF8STRING: Consider whether this should use a different seed than String.GetHashCode.

            ulong seed = Marvin.DefaultSeed;

            return(Marvin.ComputeHash32(ref DangerousGetMutableReference(), (uint)_length /* in bytes */, (uint)seed, (uint)(seed >> 32)));
        }
Example #5
0
        public void Add(int iterations, byte[] data)
        {
            ReadOnlySpan <byte> otherData = new byte[] { 1, 2, 3 };
            var bytes = new ReadOnlySpan <byte>(data);

            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    for (int i = 0; i < iterations; i++)
                    {
                        Marvin.ComputeHash(bytes, 123123123123UL);
                        Marvin.ComputeHash(otherData, 555888555888UL);
                    }
                }
            }
        }
Example #6
0
        internal static int GetHashCodeOrdinalIgnoreCase(ReadOnlySpan <char> value)
        {
            ulong seed = Marvin.DefaultSeed;

            return(Marvin.ComputeHash32OrdinalIgnoreCase(ref MemoryMarshal.GetReference(value), value.Length /* in chars, not bytes */, (uint)seed, (uint)(seed >> 32)));
        }
Example #7
0
        internal int GetHashCodeOrdinalIgnoreCase()
        {
            ulong seed = Marvin.DefaultSeed;

            return(Marvin.ComputeHash32OrdinalIgnoreCase(ref _firstChar, _stringLength /* in chars, not bytes */, (uint)seed, (uint)(seed >> 32)));
        }
 // Gets a hash code for this string.  If strings A and B are such that A.Equals(B), then
 // they will return the same hash code.
 public override int GetHashCode()
 {
     return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref _firstChar), _stringLength * 2, Marvin.DefaultSeed));
 }
Example #9
0
        public static int GetHashCode(ReadOnlySpan <char> value)
        {
            ulong seed = Marvin.DefaultSeed;

            return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref MemoryMarshal.GetReference(value)), value.Length * 2 /* in bytes, not chars */, (uint)seed, (uint)(seed >> 32)));
        }
Example #10
0
        public override int GetHashCode()
        {
            ulong seed = Marvin.DefaultSeed;

            return(Marvin.ComputeHash32(ref Unsafe.As <char, byte>(ref _firstChar), _stringLength * 2 /* in bytes, not chars */, (uint)seed, (uint)(seed >> 32)));
        }