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

revset: add Revset::count() API

The default-engine implementation is pretty much the same as iter().count(),
but custom engine may have an optimal path.
This commit is contained in:
Yuya Nishihara 2023-04-21 19:32:38 +09:00
parent 5b568cabcc
commit 0b2f0eca05
2 changed files with 6 additions and 0 deletions

View file

@ -121,6 +121,10 @@ impl<'index> Revset<'index> for RevsetImpl<'index> {
fn is_empty(&self) -> bool {
self.iter().next().is_none()
}
fn count(&self) -> usize {
self.inner.iter().count()
}
}
struct ChangeIdIndexImpl<'index> {

View file

@ -2037,6 +2037,8 @@ pub trait Revset<'index>: fmt::Debug {
fn change_id_index(&self) -> Box<dyn ChangeIdIndex + 'index>;
fn is_empty(&self) -> bool;
fn count(&self) -> usize;
}
pub trait ChangeIdIndex: Send + Sync {