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.
--- a/rust/hg-core/src/matchers.rs Fri Apr 12 14:09:55 2024 +0100
+++ b/rust/hg-core/src/matchers.rs Fri Apr 12 14:17:10 2024 +0100
@@ -354,9 +354,12 @@
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