Skip to content

Commit

Permalink
Merge branch '0.9-prerelease' of https://github.com/tkaitchuck/aHash
Browse files Browse the repository at this point in the history
…into aarch64-regression
  • Loading branch information
tkaitchuck committed Mar 27, 2024
2 parents a15c358 + 0a0e493 commit 3d20a53
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -88,7 +88,7 @@ once_cell = { version = "1.18.0", default-features = false, features = ["alloc"]

[dev-dependencies]
no-panic = "0.1.10"
criterion = {version = "0.3.2", features = ["html_reports"] }
criterion = {version = "0.5.1", features = ["html_reports"] }
seahash = "4.0"
fnv = "1.0.5"
fxhash = "0.2.1"
Expand Down
41 changes: 32 additions & 9 deletions src/aes_hash.rs
Expand Up @@ -261,13 +261,26 @@ impl Hasher for AHasherU64 {
}

#[inline]
fn write_u128(&mut self, _i: u128) {
unreachable!("Specialized hasher was called with a different type of object")
fn write_u128(&mut self, i: u128) {
let i: [u64; 2] = i.convert();
self.buffer = folded_multiply(i[0] ^ self.buffer, MULTIPLE);
self.pad = folded_multiply(i[1] ^ self.pad, MULTIPLE);
}

#[inline]
fn write_usize(&mut self, _i: usize) {
unreachable!("Specialized hasher was called with a different type of object")
#[cfg(any(
target_pointer_width = "64",
target_pointer_width = "32",
target_pointer_width = "16"
))]
fn write_usize(&mut self, i: usize) {
self.write_u64(i as u64);
}

#[inline]
#[cfg(target_pointer_width = "128")]
fn write_usize(&mut self, i: usize) {
self.write_u128(i as u128);
}
}

Expand Down Expand Up @@ -349,19 +362,29 @@ impl Hasher for AHasherStr {
fn write_u8(&mut self, _i: u8) {}

#[inline]
fn write_u16(&mut self, _i: u16) {}
fn write_u16(&mut self, i: u16) {
self.0.write_u16(i)
}

#[inline]
fn write_u32(&mut self, _i: u32) {}
fn write_u32(&mut self, i: u32) {
self.0.write_u32(i)
}

#[inline]
fn write_u64(&mut self, _i: u64) {}
fn write_u64(&mut self, i: u64) {
self.0.write_u64(i)
}

#[inline]
fn write_u128(&mut self, _i: u128) {}
fn write_u128(&mut self, i: u128) {
self.0.write_u128(i)
}

#[inline]
fn write_usize(&mut self, _i: usize) {}
fn write_usize(&mut self, i: usize) {
self.0.write_usize(i)
}
}

#[cfg(test)]
Expand Down
42 changes: 32 additions & 10 deletions src/fallback_hash.rs
Expand Up @@ -212,7 +212,6 @@ impl Hasher for AHasherU64 {
#[inline]
fn finish(&self) -> u64 {
folded_multiply(self.buffer, self.pad)
//self.buffer
}

#[inline]
Expand Down Expand Up @@ -241,13 +240,26 @@ impl Hasher for AHasherU64 {
}

#[inline]
fn write_u128(&mut self, _i: u128) {
unreachable!("Specialized hasher was called with a different type of object")
fn write_u128(&mut self, i: u128) {
let i: [u64; 2] = i.convert();
self.buffer = folded_multiply(i[0] ^ self.buffer, MULTIPLE);
self.pad = folded_multiply(i[1] ^ self.pad, MULTIPLE);
}

#[inline]
fn write_usize(&mut self, _i: usize) {
unreachable!("Specialized hasher was called with a different type of object")
#[cfg(any(
target_pointer_width = "64",
target_pointer_width = "32",
target_pointer_width = "16"
))]
fn write_usize(&mut self, i: usize) {
self.write_u64(i as u64);
}

#[inline]
#[cfg(target_pointer_width = "128")]
fn write_usize(&mut self, i: usize) {
self.write_u128(i as u128);
}
}

Expand Down Expand Up @@ -325,19 +337,29 @@ impl Hasher for AHasherStr {
fn write_u8(&mut self, _i: u8) {}

#[inline]
fn write_u16(&mut self, _i: u16) {}
fn write_u16(&mut self, i: u16) {
self.0.write_u16(i)
}

#[inline]
fn write_u32(&mut self, _i: u32) {}
fn write_u32(&mut self, i: u32) {
self.0.write_u32(i)
}

#[inline]
fn write_u64(&mut self, _i: u64) {}
fn write_u64(&mut self, i: u64) {
self.0.write_u64(i)
}

#[inline]
fn write_u128(&mut self, _i: u128) {}
fn write_u128(&mut self, i: u128) {
self.0.write_u128(i)
}

#[inline]
fn write_usize(&mut self, _i: usize) {}
fn write_usize(&mut self, i: usize) {
self.0.write_usize(i)
}
}

#[cfg(test)]
Expand Down

0 comments on commit 3d20a53

Please sign in to comment.