Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coreutils (uutils)
# * see the repository LICENSE, README, and CONTRIBUTING files for more information

# spell-checker:ignore (libs) ahash bigdecimal datetime serde gethostid kqueue libselinux mangen memmap uuhelp startswith constness expl unnested logind cfgs interner
# spell-checker:ignore (libs) bigdecimal datetime foldhash serde gethostid kqueue libselinux mangen memmap uuhelp startswith constness expl unnested logind cfgs interner

[package]
name = "coreutils"
Expand Down Expand Up @@ -311,7 +311,6 @@ readme = "README.package.md"
version = "0.7.0"

[workspace.dependencies]
ahash = "0.8.12"
ansi-width = "0.1.0"
bigdecimal = "0.4"
binary-heap-plus = "0.5.0"
Expand All @@ -330,6 +329,7 @@ dns-lookup = { version = "3.0.0" }
exacl = "0.12.0"
file_diff = "1.0.0"
filetime = "0.2.23"
foldhash = "0.2.0"
fs_extra = "1.3.0"
fts-sys = "0.2.16"
gcd = "2.3"
Expand Down
35 changes: 14 additions & 21 deletions fuzz/Cargo.lock

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

4 changes: 2 additions & 2 deletions src/uu/sort/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# spell-checker:ignore ahash bigdecimal
# spell-checker:ignore bigdecimal foldhash

[package]
name = "uu_sort"
Expand Down Expand Up @@ -44,7 +44,7 @@ uucore = { workspace = true, features = [
"i18n-collator",
] }
fluent = { workspace = true }
ahash = { workspace = true }
foldhash = { workspace = true }

[target.'cfg(not(target_os = "redox"))'.dependencies]
ctrlc = { workspace = true }
Expand Down
17 changes: 10 additions & 7 deletions src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html
// https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html

// spell-checker:ignore (misc) HFKJFK Mbdfhn getrlimit RLIMIT_NOFILE rlim bigdecimal extendedbigdecimal hexdigit behaviour keydef GETFD localeconv
// spell-checker:ignore (misc) HFKJFK Mbdfhn getrlimit RLIMIT_NOFILE rlim bigdecimal extendedbigdecimal hexdigit behaviour keydef GETFD localeconv foldhash

mod buffer_hint;
mod check;
Expand All @@ -18,21 +18,22 @@ mod merge;
mod numeric_str_cmp;
mod tmp_dir;

use ahash::AHashMap;
use bigdecimal::BigDecimal;
use chunks::LineData;
use clap::builder::ValueParser;
use clap::{Arg, ArgAction, ArgMatches, Command};
use custom_str_cmp::custom_str_cmp;
use ext_sort::ext_sort;
use foldhash::fast::FoldHasher;
use foldhash::{HashMap, SharedSeed};
use numeric_str_cmp::{NumInfo, NumInfoParseSettings, human_numeric_str_cmp, numeric_str_cmp};
use rand::{Rng, rng};
use rayon::prelude::*;
use std::cmp::Ordering;
use std::env;
use std::ffi::{OsStr, OsString};
use std::fs::{File, OpenOptions};
use std::hash::{BuildHasher, Hash, Hasher};
use std::hash::{Hash, Hasher};
use std::io::{BufRead, BufReader, BufWriter, Read, Write, stdin, stdout};
use std::num::{IntErrorKind, NonZero};
use std::ops::Range;
Expand Down Expand Up @@ -1680,7 +1681,7 @@ fn index_legacy_warnings(processed_args: &[OsString], legacy_warnings: &mut [Leg
return;
}

let mut index_by_arg = AHashMap::default();
let mut index_by_arg = HashMap::default();
for (warning_idx, warning) in legacy_warnings.iter().enumerate() {
index_by_arg.insert(warning.arg_index, warning_idx);
}
Expand Down Expand Up @@ -2925,7 +2926,7 @@ fn salt_from_random_source(path: &Path) -> UResult<[u8; SALT_LEN]> {
let mut buf = [0u8; BUF_LEN];
let mut total = 0usize;
// freeze seed for --random-source
let mut hasher = ahash::RandomState::with_seeds(1, 1, 1, 1).build_hasher();
let mut hasher = FoldHasher::with_seed(1, SharedSeed::global_fixed());

loop {
let n = reader
Expand All @@ -2951,7 +2952,7 @@ fn salt_from_random_source(path: &Path) -> UResult<[u8; SALT_LEN]> {

let first = hasher.finish();
// freeze seed for --random-source
let mut second_hasher = ahash::RandomState::with_seeds(2, 2, 2, 2).build_hasher();
let mut second_hasher = FoldHasher::with_seed(2, SharedSeed::global_fixed());
second_hasher.write(RANDOM_SOURCE_TAG);
second_hasher.write_u64(first);
let second = second_hasher.finish();
Expand All @@ -2964,7 +2965,9 @@ fn salt_from_random_source(path: &Path) -> UResult<[u8; SALT_LEN]> {

fn get_hash<T: Hash>(t: &T) -> u64 {
// Is reproducibility of get_hash itself needed for --random-source ?
ahash::RandomState::with_seeds(0, 0, 0, 0).hash_one(t)
let mut s = FoldHasher::with_seed(0, SharedSeed::global_fixed());
t.hash(&mut s);
s.finish()
}

fn random_shuffle(a: &[u8], b: &[u8], salt: &[u8]) -> Ordering {
Expand Down
Loading