Skip to content

Commit

Permalink
Move to AHash for HashSets.
Browse files Browse the repository at this point in the history
Update deps:
- clap to 4.5.16
- ctrlc to 3.4.5
  • Loading branch information
dkorunic committed Aug 16, 2024
1 parent b642190 commit 3f744a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ rayon = "1.10.0"
tempfile = "3.12.0"
anyhow = "1.0.86"
human_format = "1.1.0"
clap = { version = "4.5.15", features = ["derive"] }
ctrlc = { version = "3.4.4", features = ["termination"] }
clap = { version = "4.5.16", features = ["derive"] }
ctrlc = { version = "3.4.5", features = ["termination"] }
rm_rf = "0.6.2"
ansi_term = "0.12.1"
fs-err = "2.11.0"
indicatif = { version = "0.17.8", features = ["rayon"] }
cfg-if = "1.0"
fdlimit = "0.3.0"
ahash = "0.8.11"

[target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'.dependencies]
tikv-jemallocator = "0.6.0"
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#![warn(clippy::all, clippy::pedantic)]

use std::collections::HashSet;
use std::os::unix::fs::MetadataExt;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::time::Instant;

use ahash::AHashSet;
use anyhow::{Context, Error, Result};
use cfg_if::cfg_if;
use clap::Parser;
Expand Down Expand Up @@ -63,7 +63,7 @@ fn main() -> Result<(), Error> {
}

// Search only unique paths
let mut visited_paths = HashSet::with_capacity(args.path.len());
let mut visited_paths = AHashSet::with_capacity(args.path.len());

for path in args.path.clone() {
// Keep order of provided path arguments, but skip already visited paths
Expand Down
6 changes: 3 additions & 3 deletions src/walk.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::collections::HashSet;
use std::fs::read_dir;
use std::fs::Metadata;
use std::os::unix::fs::MetadataExt;
Expand All @@ -10,6 +9,7 @@ use std::sync::Arc;
use std::thread::sleep;
use std::time::Duration;

use ahash::AHashSet;
use ansi_term::Colour::{Green, Red, Yellow};
use anyhow::{Context, Error};
use fs_err as fs;
Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn parallel_search(
args: Arc<args::Args>,
) -> Result<(), Error> {
// Create hash set for path exclusions
let skip_path = args.skip_path.iter().cloned().collect::<HashSet<_>>();
let skip_path = args.skip_path.iter().cloned().collect::<AHashSet<_>>();

// Thread pool for status reporting and filesystem walk
let pool = Arc::new(
Expand Down Expand Up @@ -150,7 +150,7 @@ fn process_dir_entry<E>(
path_metadata: &Metadata,
size_inode_ratio: u64,
dir_entry_result: &mut Result<DirEntry<((), ())>, E>,
skip_path: &HashSet<PathBuf>,
skip_path: &AHashSet<PathBuf>,
args: &Arc<args::Args>,
dir_count_walk: &Arc<AtomicU64>,
) {
Expand Down

0 comments on commit 3f744a4

Please sign in to comment.