flat_map_iter is 11% faster than flat_map 0uo
This commit is contained in:
parent
5e17e4efda
commit
4c6163296c
3 changed files with 11 additions and 9 deletions
2
Cargo.lock
generated
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"
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -123,6 +123,9 @@ fn main() {
|
|||
for result in &results {
|
||||
match result {
|
||||
Ok(r) => {
|
||||
// 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,
|
||||
|
@ -130,6 +133,7 @@ fn main() {
|
|||
r.recommended_extension().unwrap_or_else(|| "???".into())
|
||||
);
|
||||
}
|
||||
}
|
||||
Err(f) => warn!("{}", f),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue