Skip to content

Commit de76be7

Browse files
committed
sort: Use rustc-hash
1 parent 0589d2c commit de76be7

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/sort/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ bigdecimal = { workspace = true }
2828
binary-heap-plus = { workspace = true }
2929
clap = { workspace = true }
3030
compare = { workspace = true }
31-
fnv = { workspace = true }
3231
itertools = { workspace = true }
3332
memchr = { workspace = true }
3433
rand = { workspace = true }
3534
rayon = { workspace = true }
35+
rustc-hash = { workspace = true }
3636
self_cell = { workspace = true }
3737
tempfile = { workspace = true }
3838
thiserror = { workspace = true }

src/uu/sort/src/sort.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ use clap::{Arg, ArgAction, ArgMatches, Command};
2525
use custom_str_cmp::custom_str_cmp;
2626

2727
use ext_sort::ext_sort;
28-
use fnv::FnvHasher;
2928
use numeric_str_cmp::{NumInfo, NumInfoParseSettings, human_numeric_str_cmp, numeric_str_cmp};
3029
use rand::{Rng, rng};
3130
use rayon::prelude::*;
31+
use rustc_hash::FxHashMap as HashMap;
32+
use rustc_hash::FxHasher as Hasher;
3233
use std::cmp::Ordering;
3334
use std::env;
3435
use std::ffi::{OsStr, OsString};
3536
use std::fs::{File, OpenOptions};
36-
use std::hash::{Hash, Hasher};
37+
use std::hash::Hash;
38+
use std::hash::Hasher as _;
3739
use std::io::{BufRead, BufReader, BufWriter, Read, Write, stdin, stdout};
3840
use std::num::{IntErrorKind, NonZero};
3941
use std::ops::Range;
@@ -1680,7 +1682,7 @@ fn index_legacy_warnings(processed_args: &[OsString], legacy_warnings: &mut [Leg
16801682
return;
16811683
}
16821684

1683-
let mut index_by_arg = std::collections::HashMap::new();
1685+
let mut index_by_arg = HashMap::default();
16841686
for (warning_idx, warning) in legacy_warnings.iter().enumerate() {
16851687
index_by_arg.insert(warning.arg_index, warning_idx);
16861688
}
@@ -2919,7 +2921,7 @@ fn salt_from_random_source(path: &Path) -> UResult<[u8; SALT_LEN]> {
29192921
let mut reader = open_with_open_failed_error(path)?;
29202922
let mut buf = [0u8; BUF_LEN];
29212923
let mut total = 0usize;
2922-
let mut hasher = FnvHasher::default();
2924+
let mut hasher = Hasher::default();
29232925

29242926
loop {
29252927
let n = reader
@@ -2944,7 +2946,7 @@ fn salt_from_random_source(path: &Path) -> UResult<[u8; SALT_LEN]> {
29442946
}
29452947

29462948
let first = hasher.finish();
2947-
let mut second_hasher = FnvHasher::default();
2949+
let mut second_hasher = Hasher::default();
29482950
second_hasher.write(RANDOM_SOURCE_TAG);
29492951
second_hasher.write_u64(first);
29502952
let second = second_hasher.finish();
@@ -2956,7 +2958,7 @@ fn salt_from_random_source(path: &Path) -> UResult<[u8; SALT_LEN]> {
29562958
}
29572959

29582960
fn get_hash<T: Hash>(t: &T) -> u64 {
2959-
let mut s = FnvHasher::default();
2961+
let mut s = Hasher::default();
29602962
t.hash(&mut s);
29612963
s.finish()
29622964
}

0 commit comments

Comments
 (0)