Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for upstream changes and drop xxhash
  • Loading branch information
sfackler committed Dec 19, 2014
1 parent 0a80b06 commit fc2539f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 59 deletions.
2 changes: 1 addition & 1 deletion phf/src/map.rs
Expand Up @@ -46,7 +46,7 @@ impl<K, V> fmt::Show for Map<K, V> 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, "}}")
Expand Down
2 changes: 1 addition & 1 deletion phf/src/ordered_map.rs
Expand Up @@ -52,7 +52,7 @@ impl<K, V> fmt::Show for OrderedMap<K, V> 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, "}}")
Expand Down
2 changes: 1 addition & 1 deletion phf/tests/test.rs
Expand Up @@ -141,7 +141,7 @@ mod map {
assert_eq!(Some(&$v), MAP.get(&$k));
)+
})
)
);

#[test]
fn test_array_vals() {
Expand Down
3 changes: 0 additions & 3 deletions phf_shared/Cargo.toml
Expand Up @@ -9,6 +9,3 @@ description = "Support code shared by phf and phf_mac"
name = "phf_shared"
path = "src/lib.rs"
test = false

[dependencies]
xxhash = "*"
105 changes: 52 additions & 53 deletions 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 {
Expand All @@ -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))
}
}

Expand All @@ -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);

0 comments on commit fc2539f

Please sign in to comment.