Skip to content

Commit

Permalink
index: add methods that provides commit/change_id_length
Browse files Browse the repository at this point in the history
We could add Layout struct holding these parameters, but I don't think that's
needed just for two parameters.
  • Loading branch information
yuja committed Dec 12, 2023
1 parent 3831ad4 commit c0a12a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/src/default_index/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ impl MutableIndexSegment {

pub(super) fn incremental(parent_file: Arc<ReadonlyIndexSegment>) -> Self {
let num_parent_commits = parent_file.as_composite().num_commits();
let commit_id_length = parent_file.commit_id_length;
let change_id_length = parent_file.change_id_length;
let commit_id_length = parent_file.commit_id_length();
let change_id_length = parent_file.change_id_length();
Self {
parent_file: Some(parent_file),
num_parent_commits,
Expand Down
12 changes: 10 additions & 2 deletions lib/src/default_index/readonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ pub(super) struct ReadonlyIndexSegment {
parent_file: Option<Arc<ReadonlyIndexSegment>>,
num_parent_commits: u32,
name: String,
pub(super) commit_id_length: usize,
pub(super) change_id_length: usize,
commit_id_length: usize,
change_id_length: usize,
commit_graph_entry_size: usize,
commit_lookup_entry_size: usize,
// Number of commits not counting the parent file
Expand Down Expand Up @@ -215,6 +215,14 @@ impl ReadonlyIndexSegment {
&self.name
}

pub(super) fn commit_id_length(&self) -> usize {
self.commit_id_length
}

pub(super) fn change_id_length(&self) -> usize {
self.change_id_length
}

fn graph_entry(&self, local_pos: u32) -> CommitGraphEntry {
let offset = (local_pos as usize) * self.commit_graph_entry_size;
CommitGraphEntry {
Expand Down

0 comments on commit c0a12a7

Please sign in to comment.