From 52e4bee3fe2111f2fe8caa417dca8e4e2e117397 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 12 Mar 2023 10:37:20 -0700 Subject: [PATCH] index: remove stats() from API The `stats()` function is specific to the default implementation, so it shouldn't be part of the `Index` trait. --- lib/src/default_index_store.rs | 16 ++++++++-------- lib/src/index.rs | 4 +--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/src/default_index_store.rs b/lib/src/default_index_store.rs index 794a9cc1c..4e5db7cac 100644 --- a/lib/src/default_index_store.rs +++ b/lib/src/default_index_store.rs @@ -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 { 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 { CompositeIndex(self).commit_id_to_pos(commit_id) } diff --git a/lib/src/index.rs b/lib/src/index.rs index 0884edcb6..dc1ad91d7 100644 --- a/lib/src/index.rs +++ b/lib/src/index.rs @@ -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; fn shortest_unique_commit_id_prefix_len(&self, commit_id: &CommitId) -> usize;