use u128 in map_to_range

This commit is contained in:
Riccardo Casatta 2020-10-05 09:21:40 +02:00
parent 8c82129442
commit 8ac3af68a4
No known key found for this signature in database
GPG Key ID: FD986A969E450397
1 changed files with 1 additions and 14 deletions

View File

@ -321,20 +321,7 @@ impl GCSFilterReader {
// fast reduction of hash to [0, nm) range // fast reduction of hash to [0, nm) range
fn map_to_range(hash: u64, nm: u64) -> u64 { fn map_to_range(hash: u64, nm: u64) -> u64 {
// Use this once we upgrade to rustc >= 1.26 ((hash as u128 * nm as u128) >> 64) as u64
// ((hash as u128 * nm as u128) >> 64) as u64
#[inline]
fn l(n: u64) -> u64 { n & 0xffffffff }
#[inline]
fn h(n: u64) -> u64 { n >> 32 }
let a = h(hash);
let b = l(hash);
let c = h(nm);
let d = l(nm);
a * c + h(a * d + c * b + h(b * d))
} }
/// Colomb-Rice encoded filter writer /// Colomb-Rice encoded filter writer