ok/jj
1
0
Fork 0
forked from mirrors/jj

matchers: inline RepoPathTree::add_file()

This commit is contained in:
Yuya Nishihara 2024-04-15 16:35:54 +09:00
parent 0153cc1bc7
commit f92e5b911f

View file

@ -129,7 +129,7 @@ impl FilesMatcher {
pub fn new(files: impl IntoIterator<Item = impl AsRef<RepoPath>>) -> Self { pub fn new(files: impl IntoIterator<Item = impl AsRef<RepoPath>>) -> Self {
let mut tree = RepoPathTree::new(); let mut tree = RepoPathTree::new();
for f in files { for f in files {
tree.add_file(f.as_ref()); tree.add(f.as_ref()).is_file = true;
} }
FilesMatcher { tree } FilesMatcher { tree }
} }
@ -369,10 +369,6 @@ impl RepoPathTree {
}) })
} }
fn add_file(&mut self, file: &RepoPath) {
self.add(file).is_file = true;
}
fn get(&self, dir: &RepoPath) -> Option<&RepoPathTree> { fn get(&self, dir: &RepoPath) -> Option<&RepoPathTree> {
dir.components() dir.components()
.try_fold(self, |sub, name| sub.entries.get(name)) .try_fold(self, |sub, name| sub.entries.get(name))