Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use ahash.
  • Loading branch information
renatoathaydes committed Aug 15, 2021
1 parent c93a961 commit 3e6531a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/rust/phone_encoder/Cargo.toml
Expand Up @@ -8,6 +8,7 @@ license = ""
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ahash = "0.7.4"

[dev-dependencies]
criterion = "0.3.5"
Expand Down
6 changes: 4 additions & 2 deletions src/rust/phone_encoder/src/lib.rs
Expand Up @@ -5,7 +5,7 @@ use std::io::{self, BufRead, Write};
use std::iter::FromIterator;
use std::path::Path;

pub type Dictionary = HashMap<DigitBytes, Vec<String>>;
pub type Dictionary = HashMap<DigitBytes, Vec<String>, ahash::RandomState>;

static DIGITS: [&str; 10] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];

Expand Down Expand Up @@ -50,7 +50,9 @@ pub fn print_solution(num: &str, words: &[&str], writer: &mut impl Write) {
}

pub fn load_dict(words_file: String) -> io::Result<Dictionary> {
let mut dict = HashMap::with_capacity(100);
let mut dict: Dictionary = HashMap::with_capacity_and_hasher(
100,
ahash::RandomState::default());
let words = read_lines(words_file)?;
for word in words.flatten() {
let key = word_to_number(&word);
Expand Down

0 comments on commit 3e6531a

Please sign in to comment.