Rollup merge of #92528 - tmiasko:combine-commutative, r=michaelwoerister
Make `Fingerprint::combine_commutative` associative The previous implementation swapped lower and upper 64-bits of a result of modular addition, so the function was non-associative. r? `@Aaron1011`
This commit is contained in:
commit
21ffe45631
2 changed files with 18 additions and 1 deletions
|
@ -3,6 +3,9 @@ use rustc_serialize::{Decodable, Encodable};
|
|||
use std::convert::TryInto;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct Fingerprint(u64, u64);
|
||||
|
@ -54,7 +57,7 @@ impl Fingerprint {
|
|||
|
||||
let c = a.wrapping_add(b);
|
||||
|
||||
Fingerprint((c >> 64) as u64, c as u64)
|
||||
Fingerprint(c as u64, (c >> 64) as u64)
|
||||
}
|
||||
|
||||
pub fn to_hex(&self) -> String {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue