From 8219e577d02c56ae736197d1d7a65d5f4f36c933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Sun, 16 Jan 2022 14:51:11 +1300 Subject: [PATCH] Reduce swaplock hold for tagged compile globs --- lib/src/filter/tagged.rs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/src/filter/tagged.rs b/lib/src/filter/tagged.rs index 08c29fa..f0c946c 100644 --- a/lib/src/filter/tagged.rs +++ b/lib/src/filter/tagged.rs @@ -163,9 +163,11 @@ impl TaggedFilterer { if let (Matcher::Path, Tag::Path { path, file_type }) = (matcher, tag) { let is_dir = file_type.map_or(false, |ft| matches!(ft, FileType::Dir)); + { let gc = self.glob_compiled.borrow(); if let Some(igs) = gc.as_ref() { - let _span = trace_span!("checking_compiled_filters", compiled=%"Glob") + let _span = + trace_span!("checking_compiled_filters", compiled=%"Glob") .entered(); match if path.strip_prefix(&self.origin).is_ok() { trace!("checking against path or parents"); @@ -179,11 +181,17 @@ impl TaggedFilterer { tag_match &= false; } Match::Ignore(glob) => { - if glob.from().map_or(true, |f| path.strip_prefix(f).is_ok()) { + if glob + .from() + .map_or(true, |f| path.strip_prefix(f).is_ok()) + { trace!(?glob, "positive match (pass)"); tag_match &= true; } else { - trace!(?glob, "positive match, but not in scope (ignore)"); + trace!( + ?glob, + "positive match, but not in scope (ignore)" + ); } } Match::Whitelist(glob) => { @@ -191,7 +199,9 @@ impl TaggedFilterer { } } } + } + { let ngc = self.not_glob_compiled.borrow(); if let Some(ngs) = ngc.as_ref() { let _span = @@ -209,11 +219,17 @@ impl TaggedFilterer { tag_match &= true; } Match::Ignore(glob) => { - if glob.from().map_or(true, |f| path.strip_prefix(f).is_ok()) { + if glob + .from() + .map_or(true, |f| path.strip_prefix(f).is_ok()) + { trace!(?glob, "positive match (fail)"); tag_match &= false; } else { - trace!(?glob, "positive match, but not in scope (ignore)"); + trace!( + ?glob, + "positive match, but not in scope (ignore)" + ); } } Match::Whitelist(glob) => { @@ -223,6 +239,7 @@ impl TaggedFilterer { } } } + } // those are handled with the compiled ignore filters above let tag_filters = tag_filters