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:
parent
5b568cabcc
commit
0b2f0eca05
2 changed files with 6 additions and 0 deletions
|
@ -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> {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue