Skip to content

Commit

Permalink
optimization: use fxhash
Browse files Browse the repository at this point in the history
  • Loading branch information
koraa committed Jan 18, 2020
1 parent f48780f commit a73cde6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 150 deletions.
154 changes: 8 additions & 146 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -13,4 +13,4 @@ keywords = ["cli", "uniq"]
[dependencies]
clap = "^2.33.0"
anyhow = "1.0"
ahash = "0.2.18"
fxhash = "^0.2.1"
5 changes: 2 additions & 3 deletions src/main.rs
@@ -1,11 +1,10 @@
extern crate clap;
extern crate ahash;

use std::collections::{HashSet, HashMap, hash_map};
use std::hash::{Hasher, BuildHasher};
use std::io::{stdin, BufRead, BufReader, stdout, Write, BufWriter};
use std::slice;
use ahash::ABuildHasher;
use fxhash::FxBuildHasher;
use clap::{Arg, App};
use anyhow::Result;

Expand Down Expand Up @@ -67,7 +66,7 @@ fn uniq_cmd(delim: u8) -> Result<()> {
let inp = stdin();
let mut out = BufWriter::new(out.lock());
let mut inp = BufReader::new(inp.lock());
let hasher = ABuildHasher::new();
let hasher = FxBuildHasher::default();
let mut set = HashSet::<u64, BuildIdentityHasher>::default();
let mut line = Vec::<u8>::new();
while inp.read_until(delim, &mut line)? > 0 {
Expand Down

0 comments on commit a73cde6

Please sign in to comment.