Skip to content

Commit

Permalink
foo[] -> &*foo
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Dec 11, 2014
1 parent 4546f51 commit ca8cfbf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
19 changes: 9 additions & 10 deletions phf_mac/src/lib.rs
Expand Up @@ -3,7 +3,6 @@
//! See the documentation for the `phf` crate for more details.
#![doc(html_root_url="http://sfackler.github.io/doc")]
#![feature(plugin_registrar, quote, default_type_params, macro_rules)]
#![feature(slicing_syntax)]
#![allow(unknown_features)]

extern crate rand;
Expand Down Expand Up @@ -45,11 +44,11 @@ fn expand_phf_map(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResul
None => return DummyResult::expr(sp)
};

if has_duplicates(cx, sp, entries[]) {
if has_duplicates(cx, sp, &*entries) {
return DummyResult::expr(sp);
}

let state = generate_hash(cx, sp, entries[]);
let state = generate_hash(cx, sp, &*entries);

create_map(cx, sp, entries, state)
}
Expand All @@ -60,11 +59,11 @@ fn expand_phf_set(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResul
None => return DummyResult::expr(sp)
};

if has_duplicates(cx, sp, entries[]) {
if has_duplicates(cx, sp, &*entries) {
return DummyResult::expr(sp);
}

let state = generate_hash(cx, sp, entries[]);
let state = generate_hash(cx, sp, &*entries);

create_set(cx, sp, entries, state)
}
Expand All @@ -75,11 +74,11 @@ fn expand_phf_ordered_map(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<
None => return DummyResult::expr(sp),
};

if has_duplicates(cx, sp, entries[]) {
if has_duplicates(cx, sp, &*entries) {
return DummyResult::expr(sp);
}

let state = generate_hash(cx, sp, entries[]);
let state = generate_hash(cx, sp, &*entries);

create_ordered_map(cx, sp, entries, state)
}
Expand All @@ -90,11 +89,11 @@ fn expand_phf_ordered_set(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<
None => return DummyResult::expr(sp)
};

if has_duplicates(cx, sp, entries[]) {
if has_duplicates(cx, sp, &*entries) {
return DummyResult::expr(sp);
}

let state = generate_hash(cx, sp, entries[]);
let state = generate_hash(cx, sp, &*entries);

create_ordered_set(cx, sp, entries, state)
}
Expand Down Expand Up @@ -220,7 +219,7 @@ fn has_duplicates(cx: &mut ExtCtxt, sp: Span, entries: &[Entry]) -> bool {
}

dups = true;
cx.span_err(sp, format!("duplicate key {}", pprust::expr_to_string(&**key))[]);
cx.span_err(sp, &*format!("duplicate key {}", pprust::expr_to_string(&**key)));
for span in spans.iter() {
cx.span_note(*span, "one occurrence here");
}
Expand Down
4 changes: 2 additions & 2 deletions phf_mac/src/util.rs
Expand Up @@ -58,7 +58,7 @@ impl PhfHash for Key {
fn phf_hash(&self, key: u64) -> (u32, u32, u32) {
match *self {
Key::Str(ref s) => s.get().phf_hash(key),
Key::Binary(ref b) => (**b)[].phf_hash(key),
Key::Binary(ref b) => b.phf_hash(key),
Key::Char(c) => c.phf_hash(key),
Key::U8(b) => b.phf_hash(key),
Key::I8(b) => b.phf_hash(key),
Expand Down Expand Up @@ -100,7 +100,7 @@ pub fn generate_hash(cx: &mut ExtCtxt, sp: Span, entries: &[Entry]) -> HashState
}
let time = time::precise_time_s() - start;
if os::getenv("PHF_STATS").is_some() {
cx.span_note(sp, format!("PHF generation took {} seconds", time)[]);
cx.span_note(sp, &*format!("PHF generation took {} seconds", time));
}

state
Expand Down

0 comments on commit ca8cfbf

Please sign in to comment.