diff options
Diffstat (limited to 'src/mscorlib/src/System/Numerics/Hashing/HashHelpers.cs')
-rw-r--r-- | src/mscorlib/src/System/Numerics/Hashing/HashHelpers.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mscorlib/src/System/Numerics/Hashing/HashHelpers.cs b/src/mscorlib/src/System/Numerics/Hashing/HashHelpers.cs new file mode 100644 index 0000000000..0314d1af3c --- /dev/null +++ b/src/mscorlib/src/System/Numerics/Hashing/HashHelpers.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Numerics.Hashing +{ + // Please change the corresponding file in corefx if this is changed. + + internal static class HashHelpers + { + public static int Combine(int h1, int h2) + { + // The jit optimizes this to use the ROL instruction on x86 + // Related GitHub pull request: dotnet/coreclr#1830 + uint shift5 = ((uint)h1 << 5) | ((uint)h1 >> 27); + return ((int)shift5 + h1) ^ h2; + } + } +} |