Skip to content

Commit

Permalink
Merge branch 'release-v0.7.5' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Sep 22, 2015
2 parents 7c093e8 + fda44f5 commit bb65b8c
Show file tree
Hide file tree
Showing 14 changed files with 170 additions and 31 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ rust:
script:
- (test $TRAVIS_RUST_VERSION != "nightly" || (cd phf_macros && cargo test))
- (test $TRAVIS_RUST_VERSION != "nightly" || (cd phf_macros && cargo test --features stats))
- (test $TRAVIS_RUST_VERSION != "nightly" || (cd phf_macros && cargo bench))
- (cd phf_codegen && cargo test)
- (cd phf_codegen/test && cargo test)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Rust-PHF

[![Build Status](https://travis-ci.org/sfackler/rust-phf.png?branch=master)](https://travis-ci.org/sfackler/rust-phf) [![Latest Version](https://img.shields.io/crates/v/phf.svg)](https://crates.io/crates/phf)

[Documentation](https://sfackler.github.io/rust-phf/doc/v0.7.4/phf)
[Documentation](https://sfackler.github.io/rust-phf/doc/v0.7.5/phf)

Rust-PHF is a library to generate efficient lookup tables at compile time using
[perfect hash functions](http://en.wikipedia.org/wiki/Perfect_hash_function).
Expand Down
7 changes: 1 addition & 6 deletions build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

set -e

mkdir doc

for crate in $(echo phf_shared phf_macros phf phf_codegen phf_generator); do
rm -r $crate/target
mkdir -p $crate/target
(cd $crate/target && ln -s ../../doc)
(cd $crate && cargo doc --no-deps)
(cd $crate && rm -f Cargo.lock && CARGO_TARGET_DIR=../target cargo doc --no-deps)
done
6 changes: 3 additions & 3 deletions phf/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "phf"
authors = ["Steven Fackler <sfackler@gmail.com>"]
version = "0.7.4"
version = "0.7.5"
license = "MIT"
description = "Runtime support for perfect hash function data structures"
repository = "https://github.com/sfackler/rust-phf"
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.4/phf"
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.5/phf"

[lib]
name = "phf"
Expand All @@ -14,4 +14,4 @@ test = false

[dependencies]
debug-builders = "0.1"
phf_shared = { version = "=0.7.4", path = "../phf_shared" }
phf_shared = { version = "=0.7.5", path = "../phf_shared" }
2 changes: 1 addition & 1 deletion phf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! PHF data structures can be generated via the syntax extensions in the
//! `phf_macros` crate or via code generation in the `phf_codegen` crate. See
//! the documentation of those crates for more details.
#![doc(html_root_url="https://sfackler.github.io/rust-phf/doc/v0.7.4")]
#![doc(html_root_url="https://sfackler.github.io/rust-phf/doc/v0.7.5")]
#![warn(missing_docs)]

extern crate debug_builders;
Expand Down
8 changes: 4 additions & 4 deletions phf_codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "phf_codegen"
authors = ["Steven Fackler <sfackler@gmail.com>"]
version = "0.7.4"
version = "0.7.5"
license = "MIT"
description = "Codegen library for PHF types"
repository = "https://github.com/sfackler/rust-phf"
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.4/phf_codegen"
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.5/phf_codegen"

[dependencies.phf_generator]
path = "../phf_generator"
version = "=0.7.4"
version = "=0.7.5"

[dependencies.phf_shared]
path = "../phf_shared"
version = "=0.7.4"
version = "=0.7.5"
12 changes: 11 additions & 1 deletion phf_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
//! builder.entry("world", "2");
//! // ...
//! ```
#![doc(html_root_url="http://sfackler.github.io/rust-phf/doc/v0.7.4")]
#![doc(html_root_url="http://sfackler.github.io/rust-phf/doc/v0.7.5")]
extern crate phf_shared;
extern crate phf_generator;

Expand All @@ -97,6 +97,16 @@ pub struct Map<K> {
impl<K: Hash+PhfHash+Eq+fmt::Debug> Map<K> {
/// Creates a new `phf::Map` builder.
pub fn new() -> Map<K> {
// FIXME rust#27438
//
// On Windows/MSVC there are major problems with the handling of dllimport.
// Here, because downstream build scripts only invoke generics from phf_codegen,
// the linker ends up throwing a way a bunch of static symbols we actually need.
// This works around the problem, assuming that all clients call `Map::new` by
// calling a non-generic function.
fn noop_fix_for_27438() { }
noop_fix_for_27438();

Map {
keys: vec![],
values: vec![],
Expand Down
6 changes: 3 additions & 3 deletions phf_generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "phf_generator"
authors = ["Steven Fackler <sfackler@gmail.com>"]
version = "0.7.4"
version = "0.7.5"
license = "MIT"
description = "PHF generation logic"
repository = "https://github.com/sfackler/rust-phf"
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.4/phf_generator"
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.5/phf_generator"

[dependencies]
rand = "0.3"

[dependencies.phf_shared]
path = "../phf_shared"
version = "=0.7.4"
version = "=0.7.5"
2 changes: 1 addition & 1 deletion phf_generator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc(html_root_url="http://sfackler.github.io/rust-phf/doc/v0.7.4")]
#![doc(html_root_url="http://sfackler.github.io/rust-phf/doc/v0.7.5")]
extern crate phf_shared;
extern crate rand;

Expand Down
10 changes: 5 additions & 5 deletions phf_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "phf_macros"
authors = ["Steven Fackler <sfackler@gmail.com>"]
version = "0.7.4"
version = "0.7.5"
license = "MIT"
description = "Compiler plugin for perfect hash function data structures"
repository = "https://github.com/sfackler/rust-phf"
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.4/phf_macros"
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.5/phf_macros"

[lib]
name = "phf_macros"
Expand All @@ -18,16 +18,16 @@ stats = ["time"]

[dependencies.phf_generator]
path = "../phf_generator"
version = "=0.7.4"
version = "=0.7.5"

[dependencies.phf_shared]
path = "../phf_shared"
version = "=0.7.4"
version = "=0.7.5"

[dependencies.time]
version = "0.1"
optional = true

[dev-dependencies.phf]
path = "../phf"
version = "=0.7.4"
version = "=0.7.5"
133 changes: 133 additions & 0 deletions phf_macros/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#![feature(plugin, test)]
#![plugin(phf_macros)]

extern crate test;
extern crate phf;

mod map {
use std::collections::{BTreeMap, HashMap};
use test::Bencher;

use phf;

macro_rules! map_and_match {
($map:ident, $f:ident, $($key:expr => $value:expr,)+) => {
static $map: phf::Map<&'static str, usize> = phf_map! {
$($key => $value),+
};

fn $f(key: &str) -> Option<usize> {
match key {
$($key => Some($value),)+
_ => None
}
}
}
}

map_and_match! { MAP, match_get,
"apple" => 0,
"banana" => 1,
"carrot" => 2,
"doughnut" => 3,
"eggplant" => 4,
"frankincene" => 5,
"grapes" => 6,
"haggis" => 7,
"ice cream" => 8,
"jelly beans" => 9,
"kaffir lime leaves" => 10,
"lemonade" => 11,
"mashmallows" => 12,
"nectarines" => 13,
"oranges" => 14,
"pineapples" => 15,
"quinoa" => 16,
"rosemary" => 17,
"sourdough" => 18,
"tomatoes" => 19,
"unleavened bread" => 20,
"vanilla" => 21,
"watermelon" => 22,
"xinomavro grapes" => 23,
"yogurt" => 24,
"zucchini" => 25,
}

#[bench]
fn bench_match_some(b: &mut Bencher) {
b.iter(|| {
assert_eq!(match_get("zucchini").unwrap(), 25);
})
}

#[bench]
fn bench_match_none(b: &mut Bencher) {
b.iter(|| {
assert_eq!(match_get("potato"), None);
})
}

#[bench]
fn bench_btreemap_some(b: &mut Bencher) {
let mut map = BTreeMap::new();
for (key, value) in MAP.entries() {
map.insert(*key, *value);
}

b.iter(|| {
assert_eq!(map.get("zucchini").unwrap(), &25);
})
}

#[bench]
fn bench_hashmap_some(b: &mut Bencher) {
let mut map = HashMap::new();
for (key, value) in MAP.entries() {
map.insert(*key, *value);
}

b.iter(|| {
assert_eq!(map.get("zucchini").unwrap(), &25);
})
}

#[bench]
fn bench_phf_some(b: &mut Bencher) {
b.iter(|| {
assert_eq!(MAP.get("zucchini").unwrap(), &25);
})
}

#[bench]
fn bench_btreemap_none(b: &mut Bencher) {
let mut map = BTreeMap::new();
for (key, value) in MAP.entries() {
map.insert(*key, *value);
}

b.iter(|| {
assert_eq!(map.get("potato"), None);
})
}


#[bench]
fn bench_hashmap_none(b: &mut Bencher) {
let mut map = BTreeMap::new();
for (key, value) in MAP.entries() {
map.insert(*key, *value);
}

b.iter(|| {
assert_eq!(map.get("potato"), None);
})
}

#[bench]
fn bench_phf_none(b: &mut Bencher) {
b.iter(|| {
assert_eq!(MAP.get("potato"), None);
})
}
}
6 changes: 3 additions & 3 deletions phf_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//! }
//! # fn main() {}
//! ```
#![doc(html_root_url="http://sfackler.github.io/rust-phf/doc/v0.7.4")]
#![doc(html_root_url="http://sfackler.github.io/rust-phf/doc/v0.7.5")]
#![feature(plugin_registrar, quote, rustc_private)]

extern crate syntax;
Expand All @@ -42,7 +42,7 @@ extern crate phf_generator;

use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use syntax::ast::{self, TokenTree, LitStr, LitBinary, LitByte, LitChar, Expr, ExprLit, ExprVec};
use syntax::ast::{self, TokenTree, LitStr, LitByteStr, LitByte, LitChar, Expr, ExprLit, ExprVec};
use syntax::codemap::{Span, Spanned};
use syntax::ext::base::{DummyResult,
ExtCtxt,
Expand Down Expand Up @@ -222,7 +222,7 @@ fn parse_key(cx: &mut ExtCtxt, e: &Expr) -> Option<Key> {
ExprLit(ref lit) => {
match lit.node {
ast::LitStr(ref s, _) => Some(Key::Str(s.clone())),
ast::LitBinary(ref b) => Some(Key::Binary(b.clone())),
ast::LitByteStr(ref b) => Some(Key::Binary(b.clone())),
ast::LitByte(b) => Some(Key::U8(b)),
ast::LitChar(c) => Some(Key::Char(c)),
ast::LitInt(i, ast::SignedIntLit(ast::TyI8, ast::Plus)) => Some(Key::I8(i as i8)),
Expand Down
4 changes: 2 additions & 2 deletions phf_shared/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "phf_shared"
authors = ["Steven Fackler <sfackler@gmail.com>"]
version = "0.7.4"
version = "0.7.5"
license = "MIT"
description = "Support code shared by PHF libraries"
repository = "https://github.com/sfackler/rust-phf"
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.4/phf_shared"
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.5/phf_shared"

[lib]
name = "phf_shared"
Expand Down
2 changes: 1 addition & 1 deletion phf_shared/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc(html_root_url="http://sfackler.github.io/rust-phf/doc/v0.7.4")]
#![doc(html_root_url="http://sfackler.github.io/rust-phf/doc/v0.7.5")]

use std::hash::{Hasher, Hash, SipHasher};

Expand Down

0 comments on commit bb65b8c

Please sign in to comment.