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.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayvec"
|
name = "arrayvec"
|
||||||
version = "0.5.2"
|
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
|
// split the entries into chunks of 32, and iterate over each chunk of entries in a separate thread
|
||||||
return entries
|
return entries
|
||||||
.par_chunks(CHUNKS)
|
.par_chunks(CHUNKS)
|
||||||
.flat_map(|chunk| {
|
.flat_map_iter(|chunk| {
|
||||||
chunk
|
chunk
|
||||||
.iter() // iter over the chunk, which is a slice of DirEntry structs
|
.iter() // iter over the chunk, which is a slice of DirEntry structs
|
||||||
.map(|entry| scan_file(entry, canonical_paths))
|
.map(|entry| scan_file(entry, canonical_paths))
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -123,12 +123,16 @@ fn main() {
|
||||||
for result in &results {
|
for result in &results {
|
||||||
match result {
|
match result {
|
||||||
Ok(r) => {
|
Ok(r) => {
|
||||||
debug!(
|
// check to see if debug logging is enabled before invoking debug! macro
|
||||||
"{:?} is of type {}, should have extension \"{}\"",
|
// https://github.com/rust-lang/log/pull/394#issuecomment-630490343
|
||||||
r.file,
|
if log::max_level() >= log::Level::Debug {
|
||||||
r.mime,
|
debug!(
|
||||||
r.recommended_extension().unwrap_or_else(|| "???".into())
|
"{:?} is of type {}, should have extension \"{}\"",
|
||||||
);
|
r.file,
|
||||||
|
r.mime,
|
||||||
|
r.recommended_extension().unwrap_or_else(|| "???".into())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(f) => warn!("{}", f),
|
Err(f) => warn!("{}", f),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue