mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-31 16:40:22 +00:00
index: remove local-global pos round trip from entry_by_id()
This commit is contained in:
parent
249449ff1a
commit
89928ffdd8
1 changed files with 8 additions and 5 deletions
|
@ -157,6 +157,14 @@ impl<'a> CompositeIndex<'a> {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn entry_by_id(&self, commit_id: &CommitId) -> Option<IndexEntry<'a>> {
|
||||||
|
self.ancestor_index_segments().find_map(|segment| {
|
||||||
|
let local_pos = segment.commit_id_to_pos(commit_id)?;
|
||||||
|
let pos = IndexPosition(local_pos.0 + segment.num_parent_commits());
|
||||||
|
Some(IndexEntry::new(segment, pos, local_pos))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn commit_id_to_pos(&self, commit_id: &CommitId) -> Option<IndexPosition> {
|
pub fn commit_id_to_pos(&self, commit_id: &CommitId) -> Option<IndexPosition> {
|
||||||
self.ancestor_index_segments().find_map(|segment| {
|
self.ancestor_index_segments().find_map(|segment| {
|
||||||
let LocalPosition(local_pos) = segment.commit_id_to_pos(commit_id)?;
|
let LocalPosition(local_pos) = segment.commit_id_to_pos(commit_id)?;
|
||||||
|
@ -181,11 +189,6 @@ impl<'a> CompositeIndex<'a> {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn entry_by_id(&self, commit_id: &CommitId) -> Option<IndexEntry<'a>> {
|
|
||||||
self.commit_id_to_pos(commit_id)
|
|
||||||
.map(|pos| self.entry_by_pos(pos))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn is_ancestor_pos(
|
pub(super) fn is_ancestor_pos(
|
||||||
&self,
|
&self,
|
||||||
ancestor_pos: IndexPosition,
|
ancestor_pos: IndexPosition,
|
||||||
|
|
Loading…
Reference in a new issue