From fae38224221de36301dcad461ad655209e2ec15e Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Tue, 29 Nov 2022 18:14:09 +0900 Subject: [PATCH] revset: inline FilterRevsetIterator by using .filter() --- lib/src/revset.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/lib/src/revset.rs b/lib/src/revset.rs index e9f27ad37..f987b5a3a 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -1433,23 +1433,7 @@ struct FilterRevset<'revset, 'repo: 'revset> { impl<'repo> Revset<'repo> for FilterRevset<'_, 'repo> { fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> { - RevsetIterator::new(Box::new(FilterRevsetIterator { - iter: self.candidates.iter(), - predicate: self.predicate.as_ref(), - })) - } -} - -struct FilterRevsetIterator<'revset, 'repo> { - iter: RevsetIterator<'revset, 'repo>, - predicate: &'revset dyn Fn(&IndexEntry<'repo>) -> bool, -} - -impl<'revset, 'repo> Iterator for FilterRevsetIterator<'revset, 'repo> { - type Item = IndexEntry<'repo>; - - fn next(&mut self) -> Option { - self.iter.find(self.predicate) + RevsetIterator::new(Box::new(self.candidates.iter().filter(&self.predicate))) } }