# HG changeset patch # User Arseniy Alekseyev # Date 2024-04-12 13:17:10 # Node ID cae0be933434975bdcd07d94533b9059d972836b # Parent 529a655874fb91c2f6b3e2bbf0b912decd8f941e match: small tweak to PatternMatcher.visit_children_set This makes it a bit more efficient (avoid a computation in case of early return), and in my opinion clearer. diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -354,9 +354,12 @@ impl<'a> Matcher for PatternMatcher<'a> if self.prefix && self.files.contains(directory) { return VisitChildrenSet::Recursive; } - let path_or_parents_in_set = dir_ancestors(directory) - .any(|parent_dir| self.files.contains(parent_dir)); - if self.dirs.contains(directory) || path_or_parents_in_set { + if self.dirs.contains(directory) { + return VisitChildrenSet::This; + } + if dir_ancestors(directory) + .any(|parent_dir| self.files.contains(parent_dir)) + { VisitChildrenSet::This } else { VisitChildrenSet::Empty