Skip to content

Commit

Permalink
Use entry API on hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Sep 27, 2014
1 parent f2b4d79 commit 4b99d04
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions phf_mac/src/lib.rs
Expand Up @@ -10,6 +10,7 @@ extern crate time;
extern crate rustc;

use std::collections::HashMap;
use std::collections::hashmap::{Occupied, Vacant};
use syntax::ast::{mod, TokenTree, LitStr, LitBinary, LitByte, LitChar, Expr, ExprLit};
use syntax::codemap::Span;
use syntax::ext::base::{DummyResult,
Expand Down Expand Up @@ -206,8 +207,10 @@ fn has_duplicates(cx: &mut ExtCtxt, sp: Span, entries: &[Entry]) -> bool {
let mut dups = false;
let mut strings = HashMap::new();
for entry in entries.iter() {
let &(ref mut spans, _) = strings.find_or_insert(&entry.key_contents,
(vec![], &entry.key));
let &(ref mut spans, _) = match strings.entry(&entry.key_contents) {
Occupied(e) => e.into_mut(),
Vacant(e) => e.set((vec![], &entry.key)),
};
spans.push(entry.key.span);
}

Expand Down

0 comments on commit 4b99d04

Please sign in to comment.