Skip to content
Permalink
Browse files
optimization: use fxhash
  • Loading branch information
koraa committed Jan 18, 2020
1 parent f48780f commit a73cde6bcafd37c71096f4569080b2cc42c5b755
Showing 3 changed files with 11 additions and 150 deletions.

Some generated files are not rendered by default. Learn more.

@@ -13,4 +13,4 @@ keywords = ["cli", "uniq"]
[dependencies]
clap = "^2.33.0"
anyhow = "1.0"
ahash = "0.2.18"
fxhash = "^0.2.1"
@@ -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;

@@ -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 {

0 comments on commit a73cde6

Please sign in to comment.