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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ rayon = "1.10"
regex = "1.10.4"
rlimit = "0.11.0"
rstest = "0.26.0"
rustc-hash = "2.1.1"
rust-ini = "0.21.0"
same-file = "1.0.6"
self_cell = "1.0.4"
Expand Down
2 changes: 1 addition & 1 deletion src/uu/shuf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rand_core = { workspace = true }
sha3 = { workspace = true }
uucore = { workspace = true }
fluent = { workspace = true }
rustc-hash = "2.1.1"
rustc-hash = { workspace = true }

[[bin]]
name = "shuf"
Expand Down
1 change: 1 addition & 0 deletions src/uu/tsort/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fluent = { workspace = true }
string-interner = { workspace = true }
thiserror = { workspace = true }
uucore = { workspace = true }
rustc-hash = { workspace = true }

[target.'cfg(unix)'.dependencies]
nix = { workspace = true, features = ["fs"] }
Expand Down
15 changes: 8 additions & 7 deletions src/uu/tsort/src/tsort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
//spell-checker:ignore TAOCP indegree fadvise FADV
//spell-checker:ignore (libs) interner uclibc
use clap::{Arg, ArgAction, Command};
use rustc_hash::FxHashMap;
use std::collections::VecDeque;
use std::collections::hash_map::Entry;
use std::collections::{HashMap, VecDeque};
use std::ffi::OsString;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
Expand All @@ -19,7 +20,7 @@ use uucore::{format_usage, show, translate};

// short types for switching interning behavior on the fly.
type Sym = string_interner::symbol::SymbolUsize;
type Interner = StringInterner<BucketBackend<Sym>>;
type Interner = StringInterner<BucketBackend<Sym>, rustc_hash::FxBuildHasher>;

mod options {
pub const FILE: &str = "file";
Expand Down Expand Up @@ -224,18 +225,18 @@ impl Node {

struct Graph {
name_sym: Sym,
nodes: HashMap<Sym, Node>,
nodes: FxHashMap<Sym, Node>,
interner: Interner,
}

impl Graph {
fn new(name: String) -> Self {
let mut interner = Interner::new();
let mut interner = Interner::with_hasher(rustc_hash::FxBuildHasher);
let name_sym = interner.get_or_intern(name);
Self {
name_sym,
interner,
nodes: HashMap::default(),
nodes: FxHashMap::default(),
}
}

Expand Down Expand Up @@ -357,7 +358,7 @@ impl Graph {
let mut nodes: Vec<_> = self.nodes.keys().copied().collect();
nodes.sort_unstable_by(|a, b| self.get_node_name(*a).cmp(self.get_node_name(*b)));

let mut visited = HashMap::new();
let mut visited = FxHashMap::default();
let mut stack = Vec::with_capacity(self.nodes.len());
for &node in &nodes {
if self.dfs(node, &mut visited, &mut stack) {
Expand All @@ -376,7 +377,7 @@ impl Graph {
fn dfs<'a>(
&'a self,
node: Sym,
visited: &mut HashMap<Sym, VisitedState>,
visited: &mut FxHashMap<Sym, VisitedState>,
stack: &mut Vec<(Sym, &'a [Sym])>,
) -> bool {
stack.push((
Expand Down
Loading