From fc2539f7893ef0f833a8c13ec77ba317bd8bf43e Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Fri, 19 Dec 2014 08:33:43 -0800 Subject: [PATCH] Fix for upstream changes and drop xxhash --- phf/src/map.rs | 2 +- phf/src/ordered_map.rs | 2 +- phf/tests/test.rs | 2 +- phf_shared/Cargo.toml | 3 -- phf_shared/src/lib.rs | 105 ++++++++++++++++++++--------------------- 5 files changed, 55 insertions(+), 59 deletions(-) diff --git a/phf/src/map.rs b/phf/src/map.rs index b1f80cd4..206277ae 100644 --- a/phf/src/map.rs +++ b/phf/src/map.rs @@ -46,7 +46,7 @@ impl fmt::Show for Map where K: fmt::Show, V: fmt::Show { if !first { try!(write!(fmt, ", ")); } - try!(write!(fmt, "{}: {}", k, v)) + try!(write!(fmt, "{}: {}", k, v)); first = false; } write!(fmt, "}}") diff --git a/phf/src/ordered_map.rs b/phf/src/ordered_map.rs index 49da01f8..a7113129 100644 --- a/phf/src/ordered_map.rs +++ b/phf/src/ordered_map.rs @@ -52,7 +52,7 @@ impl fmt::Show for OrderedMap where K: fmt::Show, V: fmt::Show { if !first { try!(write!(fmt, ", ")); } - try!(write!(fmt, "{}: {}", k, v)) + try!(write!(fmt, "{}: {}", k, v)); first = false; } write!(fmt, "}}") diff --git a/phf/tests/test.rs b/phf/tests/test.rs index 8341b677..5eafb83a 100644 --- a/phf/tests/test.rs +++ b/phf/tests/test.rs @@ -141,7 +141,7 @@ mod map { assert_eq!(Some(&$v), MAP.get(&$k)); )+ }) - ) + ); #[test] fn test_array_vals() { diff --git a/phf_shared/Cargo.toml b/phf_shared/Cargo.toml index a23dbedd..fcac34fe 100644 --- a/phf_shared/Cargo.toml +++ b/phf_shared/Cargo.toml @@ -9,6 +9,3 @@ description = "Support code shared by phf and phf_mac" name = "phf_shared" path = "src/lib.rs" test = false - -[dependencies] -xxhash = "*" diff --git a/phf_shared/src/lib.rs b/phf_shared/src/lib.rs index e00e61fd..d111cebb 100644 --- a/phf_shared/src/lib.rs +++ b/phf_shared/src/lib.rs @@ -1,9 +1,8 @@ #![feature(macro_rules)] - -extern crate xxhash; extern crate core; -use self::core::kinds::Sized; +use core::hash::sip; +use core::kinds::Sized; #[inline] pub fn displace(f1: u32, f2: u32, d1: u32, d2: u32) -> u32 { @@ -29,28 +28,28 @@ pub trait PhfHash for Sized? { impl<'a> PhfHash for &'a str { #[inline] fn phf_hash(&self, seed: u64) -> (u32, u32, u32) { - split(xxhash::hash_with_seed(seed, self)) + split(sip::hash_with_keys(seed, 0, self)) } } impl<'a> PhfHash for &'a [u8] { #[inline] fn phf_hash(&self, seed: u64) -> (u32, u32, u32) { - split(xxhash::oneshot(*self, seed)) + split(sip::hash_with_keys(seed, 0, self)) } } impl PhfHash for str { #[inline] fn phf_hash(&self, seed: u64) -> (u32, u32, u32) { - split(xxhash::hash_with_seed(seed, &self)) + split(sip::hash_with_keys(seed, 0, &self)) } } impl PhfHash for [u8] { #[inline] fn phf_hash(&self, seed: u64) -> (u32, u32, u32) { - split(xxhash::oneshot(self, seed)) + split(sip::hash_with_keys(seed, 0, &self)) } } @@ -60,63 +59,63 @@ macro_rules! sip_impl( impl PhfHash for $t { #[inline] fn phf_hash(&self, seed: u64) -> (u32, u32, u32) { - split(xxhash::hash_with_seed(seed, self)) + split(sip::hash_with_keys(seed, 0, self)) } } ) -) +); -sip_impl!(u8) -sip_impl!(i8) -sip_impl!(u16) -sip_impl!(i16) -sip_impl!(u32) -sip_impl!(i32) -sip_impl!(u64) -sip_impl!(i64) -sip_impl!(char) -sip_impl!(bool) +sip_impl!(u8); +sip_impl!(i8); +sip_impl!(u16); +sip_impl!(i16); +sip_impl!(u32); +sip_impl!(i32); +sip_impl!(u64); +sip_impl!(i64); +sip_impl!(char); +sip_impl!(bool); macro_rules! array_impl( ($t:ty, $n:expr) => ( impl PhfHash for [$t, ..$n] { #[inline] fn phf_hash(&self, seed: u64) -> (u32, u32, u32) { - split(xxhash::oneshot(self, seed)) + split(sip::hash_with_keys(seed, 0, self.as_slice())) } } ) -) +); -array_impl!(u8, 1) -array_impl!(u8, 2) -array_impl!(u8, 3) -array_impl!(u8, 4) -array_impl!(u8, 5) -array_impl!(u8, 6) -array_impl!(u8, 7) -array_impl!(u8, 8) -array_impl!(u8, 9) -array_impl!(u8, 10) -array_impl!(u8, 11) -array_impl!(u8, 12) -array_impl!(u8, 13) -array_impl!(u8, 14) -array_impl!(u8, 15) -array_impl!(u8, 16) -array_impl!(u8, 17) -array_impl!(u8, 18) -array_impl!(u8, 19) -array_impl!(u8, 20) -array_impl!(u8, 21) -array_impl!(u8, 22) -array_impl!(u8, 23) -array_impl!(u8, 24) -array_impl!(u8, 25) -array_impl!(u8, 26) -array_impl!(u8, 27) -array_impl!(u8, 28) -array_impl!(u8, 29) -array_impl!(u8, 30) -array_impl!(u8, 31) -array_impl!(u8, 32) +array_impl!(u8, 1); +array_impl!(u8, 2); +array_impl!(u8, 3); +array_impl!(u8, 4); +array_impl!(u8, 5); +array_impl!(u8, 6); +array_impl!(u8, 7); +array_impl!(u8, 8); +array_impl!(u8, 9); +array_impl!(u8, 10); +array_impl!(u8, 11); +array_impl!(u8, 12); +array_impl!(u8, 13); +array_impl!(u8, 14); +array_impl!(u8, 15); +array_impl!(u8, 16); +array_impl!(u8, 17); +array_impl!(u8, 18); +array_impl!(u8, 19); +array_impl!(u8, 20); +array_impl!(u8, 21); +array_impl!(u8, 22); +array_impl!(u8, 23); +array_impl!(u8, 24); +array_impl!(u8, 25); +array_impl!(u8, 26); +array_impl!(u8, 27); +array_impl!(u8, 28); +array_impl!(u8, 29); +array_impl!(u8, 30); +array_impl!(u8, 31); +array_impl!(u8, 32);