mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-10 05:59:25 +02:00
Don't traverse directory stack if we don't need to.
This commit is contained in:
@@ -82,7 +82,10 @@ pub struct Ignore {
|
|||||||
overrides: Overrides,
|
overrides: Overrides,
|
||||||
/// A file type matcher.
|
/// A file type matcher.
|
||||||
types: Types,
|
types: Types,
|
||||||
|
/// Whether to ignore hidden files or not.
|
||||||
ignore_hidden: bool,
|
ignore_hidden: bool,
|
||||||
|
/// When true, don't look at .gitignore or .agignore files for ignore
|
||||||
|
/// rules.
|
||||||
no_ignore: bool,
|
no_ignore: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,15 +210,17 @@ impl Ignore {
|
|||||||
debug!("{} ignored because it is hidden", path.display());
|
debug!("{} ignored because it is hidden", path.display());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for id in self.stack.iter().rev().filter_map(|id| id.as_ref()) {
|
if !self.no_ignore {
|
||||||
let mat = id.matched(path, is_dir);
|
for id in self.stack.iter().rev().filter_map(|id| id.as_ref()) {
|
||||||
if let Some(is_ignored) = self.ignore_match(path, mat) {
|
let mat = id.matched(path, is_dir);
|
||||||
if is_ignored {
|
if let Some(is_ignored) = self.ignore_match(path, mat) {
|
||||||
return true;
|
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);
|
let mat = self.types.matched(path, is_dir);
|
||||||
|
Reference in New Issue
Block a user