Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ public static int CountDigits(uint value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int CountHexDigits(ulong value)
{
int right = 64 - BitOps.LeadingZeroCount(value | 1);
return (right + 3) >> 2;
return (64 - BitOps.LeadingZeroCount(value | 1) + 3) >> 2;
}


// Counts the number of trailing '0' digits in a decimal number.
// e.g., value = 0 => retVal = 0, valueWithoutTrailingZeros = 0
// value = 1234 => retVal = 0, valueWithoutTrailingZeros = 1234
Expand Down
8 changes: 2 additions & 6 deletions src/System.Private.CoreLib/shared/System/HashCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,13 @@ private static void Initialize(out uint v1, out uint v2, out uint v3, out uint v
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint Round(uint hash, uint input)
{
hash += input * Prime2;
hash = BitOps.RotateLeft(hash, 13);
hash *= Prime1;
return hash;
return BitOps.RotateLeft(hash + input * Prime2, 13) * Prime1;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint QueueRound(uint hash, uint queuedValue)
{
hash += queuedValue * Prime3;
return BitOps.RotateLeft(hash, 17) * Prime4;
return BitOps.RotateLeft(hash + queuedValue * Prime3, 17) * Prime4;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down