Mercurial > hg
changeset 51567:cae0be933434 stable
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.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Fri, 12 Apr 2024 14:17:10 +0100 |
parents | 529a655874fb |
children | 2a89d2f6336f |
files | rust/hg-core/src/matchers.rs |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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