From f5c85827cea05d11e1c0c50aa34e07361313f659 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Thu, 15 Sep 2016 12:40:28 -0400 Subject: Don't traverse directory stack if we don't need to. --- src/ignore.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/ignore.rs b/src/ignore.rs index 26124f1c..09c0b302 100644 --- a/src/ignore.rs +++ b/src/ignore.rs @@ -82,7 +82,10 @@ pub struct Ignore { overrides: Overrides, /// A file type matcher. types: Types, + /// Whether to ignore hidden files or not. ignore_hidden: bool, + /// When true, don't look at .gitignore or .agignore files for ignore + /// rules. no_ignore: bool, } @@ -207,15 +210,17 @@ impl Ignore { debug!("{} ignored because it is hidden", path.display()); return true; } - for id in self.stack.iter().rev().filter_map(|id| id.as_ref()) { - let mat = id.matched(path, is_dir); - if let Some(is_ignored) = self.ignore_match(path, mat) { - if is_ignored { - return true; + if !self.no_ignore { + for id in self.stack.iter().rev().filter_map(|id| id.as_ref()) { + let mat = id.matched(path, is_dir); + if let Some(is_ignored) = self.ignore_match(path, mat) { + if is_ignored { + return true; + } + // If this path is whitelisted by an ignore, then + // fallthrough and let the file type matcher have a say. + break; } - // If this path is whitelisted by an ignore, then fallthrough - // and let the file type matcher have a say. - break; } } let mat = self.types.matched(path, is_dir); -- cgit v1.2.3