| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | // See the LICENSE file in the project root for more information. |
| | | 4 | | |
| | | 5 | | namespace System.Numerics.Hashing |
| | | 6 | | { |
| | | 7 | | internal static class HashHelpers |
| | | 8 | | { |
| | 0 | 9 | | public static readonly int RandomSeed = Guid.NewGuid().GetHashCode(); |
| | | 10 | | |
| | | 11 | | public static int Combine(int h1, int h2) |
| | 1 | 12 | | { |
| | | 13 | | unchecked |
| | 1 | 14 | | { |
| | | 15 | | // RyuJIT optimizes this to use the ROL instruction |
| | | 16 | | // Related GitHub pull request: dotnet/coreclr#1830 |
| | 1 | 17 | | uint rol5 = ((uint)h1 << 5) | ((uint)h1 >> 27); |
| | 1 | 18 | | return ((int)rol5 + h1) ^ h2; |
| | | 19 | | } |
| | 1 | 20 | | } |
| | | 21 | | } |
| | | 22 | | } |