Browse Source

flat_map_iter is 11% faster than flat_map 0uo

master
Lynne Megido 3 weeks ago
parent
commit
4c6163296c
Signed by: lynnesbian GPG Key ID: F0A184B5213D9F90
  1. 2
      Cargo.lock
  2. 2
      src/files.rs
  3. 16
      src/main.rs

2
Cargo.lock generated

@ -1,7 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "arrayvec"
version = "0.5.2"

2
src/files.rs

@ -150,7 +150,7 @@ pub fn scan_from_walkdir(
// split the entries into chunks of 32, and iterate over each chunk of entries in a separate thread
return entries
.par_chunks(CHUNKS)
.flat_map(|chunk| {
.flat_map_iter(|chunk| {
chunk
.iter() // iter over the chunk, which is a slice of DirEntry structs
.map(|entry| scan_file(entry, canonical_paths))

16
src/main.rs

@ -123,12 +123,16 @@ fn main() {
for result in &results {
match result {
Ok(r) => {
debug!(
"{:?} is of type {}, should have extension \"{}\"",
r.file,
r.mime,
r.recommended_extension().unwrap_or_else(|| "???".into())
);
// check to see if debug logging is enabled before invoking debug! macro
// https://github.com/rust-lang/log/pull/394#issuecomment-630490343
if log::max_level() >= log::Level::Debug {
debug!(
"{:?} is of type {}, should have extension \"{}\"",
r.file,
r.mime,
r.recommended_extension().unwrap_or_else(|| "???".into())
);
}
}
Err(f) => warn!("{}", f),
}

Loading…
Cancel
Save