From 32a321aafdf245261fd187cb54afdb2435b6a754 Mon Sep 17 00:00:00 2001 From: Matthias Reitinger Date: Tue, 3 Oct 2017 17:29:38 +0200 Subject: [PATCH] Extract entry extension only when there is an extension filter --- src/main.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index b260b52..fa253d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -307,14 +307,11 @@ fn scan(root: &Path, pattern: Arc, base: &Path, config: Arc) { } // Filter out unwanted extensions. - match (&config.extension, entry.path().extension()) { - (&None, _) => (), - (&Some(_), None) => return ignore::WalkState::Continue, - (&Some(ref e1), Some(e2)) => { - if e1 != &e2.to_string_lossy().to_lowercase() { - return ignore::WalkState::Continue; - } - }, + if let Some(ref filter_ext) = config.extension { + let entry_ext = entry.path().extension().map(|e| e.to_string_lossy().to_lowercase()); + if entry_ext.map_or(false, |ext| ext != *filter_ext) { + return ignore::WalkState::Continue; + } } let path_rel_buf = match fshelper::path_relative_from(entry.path(), &*base) {