ignore: speed up Gitignore::empty

This commit makes Gitignore::empty a bit faster by avoiding allocation
and manually specializing the implementation instead of routing it through
the GitignoreBuilder.

This helps improve uses of ripgrep that traverse *many* directories, and
in particular, when the use of ignores is disabled via command line
switches.

Fixes #835, Closes #836
This commit is contained in:
Andrew Gallant
2018-04-24 10:42:19 -04:00
parent 1266de3d4c
commit ab64da73ab
4 changed files with 24 additions and 5 deletions

View File

@@ -209,7 +209,9 @@ impl Ignore {
fn add_child_path(&self, dir: &Path) -> (IgnoreInner, Option<Error>) {
let mut errs = PartialErrorBuilder::default();
let custom_ig_matcher =
{
if self.0.custom_ignore_filenames.is_empty() {
Gitignore::empty()
} else {
let (m, err) =
create_gitignore(&dir, &self.0.custom_ignore_filenames);
errs.maybe_push(err);