index: remove stats() from API

The `stats()` function is specific to the default implementation, so
it shouldn't be part of the `Index` trait.
This commit is contained in:
Martin von Zweigbergk 2023-03-12 10:37:20 -07:00 committed by Martin von Zweigbergk
parent 5423feb8e1
commit 52e4bee3fe
2 changed files with 9 additions and 11 deletions

View file

@ -675,6 +675,10 @@ impl MutableIndexImpl {
IndexLoadError::IoError(err) => err,
})
}
pub fn stats(&self) -> IndexStats {
CompositeIndex(self).stats()
}
}
impl Index for MutableIndexImpl {
@ -686,10 +690,6 @@ impl Index for MutableIndexImpl {
CompositeIndex(self).num_commits()
}
fn stats(&self) -> IndexStats {
CompositeIndex(self).stats()
}
fn commit_id_to_pos(&self, commit_id: &CommitId) -> Option<IndexPosition> {
CompositeIndex(self).commit_id_to_pos(commit_id)
}
@ -1748,6 +1748,10 @@ impl ReadonlyIndexImpl {
}
}
}
pub fn stats(&self) -> IndexStats {
CompositeIndex(self).stats()
}
}
impl Index for ReadonlyIndexImpl {
@ -1759,10 +1763,6 @@ impl Index for ReadonlyIndexImpl {
CompositeIndex(self).num_commits()
}
fn stats(&self) -> IndexStats {
CompositeIndex(self).stats()
}
fn commit_id_to_pos(&self, commit_id: &CommitId) -> Option<IndexPosition> {
CompositeIndex(self).commit_id_to_pos(commit_id)
}

View file

@ -20,7 +20,7 @@ use thiserror::Error;
use crate::backend::{CommitId, ObjectId};
use crate::commit::Commit;
use crate::default_index_store::{IndexEntry, IndexPosition, IndexStats, RevWalk};
use crate::default_index_store::{IndexEntry, IndexPosition, RevWalk};
use crate::op_store::OperationId;
use crate::operation::Operation;
use crate::store::Store;
@ -50,8 +50,6 @@ pub trait Index {
fn num_commits(&self) -> u32;
fn stats(&self) -> IndexStats;
fn commit_id_to_pos(&self, commit_id: &CommitId) -> Option<IndexPosition>;
fn shortest_unique_commit_id_prefix_len(&self, commit_id: &CommitId) -> usize;