Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams committed Oct 19, 2019
1 parent 6dfe18b commit a16535d
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,12 @@ public static uint FastRange(uint index, uint range)
// Using fastrange from Daniel Lemire https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
//
// While fastrange is "fair"; it expects an evenly distributed hashCode
// from [0,2^32) to produce a distibuted range. As many hashCodes in .NET
// from [0,2^32) to produce a distributed range. As many hashCodes in .NET
// are generated with the high entropy in the LSB we need to redistribute
// the hash; for this we use Crc32. These two together allow us to skip the
// more costly idiv instruction.

const uint CrcReflected = 0xEDB88320;
return (uint)((Sse42.Crc32(CrcReflected, index) * (ulong)range) >> 32);
return (uint)((Sse42.Crc32(0, index) * (ulong)range) >> 32);
}
else
{
Expand Down

0 comments on commit a16535d

Please sign in to comment.