History

[commitgraph] refactor

Sebastian Thiel committed 6 years ago

Commit c4b14c11 parent 6f90bee4 files · +18 −18Browse files

Showing the changes to git-commitgraph/src/graph (1 of 4 files). Show all

Unified · Split

git-commitgraph/src/graph/access.rs+7−7
@@ -8,17 +8,17 @@ use git_object::borrowed; · 7 unmodified lines
8impl Graph {8impl Graph {
9 pub fn commit_at(&self, pos: graph::Position) -> Commit<'_> {9 pub fn commit_at(&self, pos: graph::Position) -> Commit<'_> {
10 let r = self.lookup_by_pos(pos);10 let r = self.lookup_by_pos(pos);
11 r.file.commit_at(r.lex_pos)11 r.file.commit_at(r.pos)
12 }12 }
13 13
14 pub fn commit_by_id(&self, id: borrowed::Id<'_>) -> Option<Commit<'_>> {14 pub fn commit_by_id(&self, id: borrowed::Id<'_>) -> Option<Commit<'_>> {
15 let r = self.lookup_by_id(id)?;15 let r = self.lookup_by_id(id)?;
16 Some(r.file.commit_at(r.lex_pos))16 Some(r.file.commit_at(r.file_pos))
17 }17 }
18 18
19 pub fn id_at(&self, pos: graph::Position) -> borrowed::Id<'_> {19 pub fn id_at(&self, pos: graph::Position) -> borrowed::Id<'_> {
20 let r = self.lookup_by_pos(pos);20 let r = self.lookup_by_pos(pos);
21 r.file.id_at(r.lex_pos)21 r.file.id_at(r.pos)
22 }22 }
23 23
24 /// Iterate over commits in unsorted order.24 /// Iterate over commits in unsorted order.
@@ -48,7 +48,7 @@ impl Graph { · 23 unmodified lines
48 if let Some(lex_pos) = file.lookup(id) {48 if let Some(lex_pos) = file.lookup(id) {
49 return Some(LookupByIdResult {49 return Some(LookupByIdResult {
50 file,50 file,
51 lex_pos,51 file_pos: lex_pos,
52 graph_pos: graph::Position(current_file_start + lex_pos.0),52 graph_pos: graph::Position(current_file_start + lex_pos.0),
53 });53 });
54 }54 }
@@ -65,7 +65,7 @@ impl Graph { · 10 unmodified lines
65 None => {65 None => {
66 return LookupByPositionResult {66 return LookupByPositionResult {
67 file,67 file,
68 lex_pos: file::Position(remaining),68 pos: file::Position(remaining),
69 }69 }
70 }70 }
71 }71 }
@@ -78,11 +78,11 @@ impl Graph { · 6 unmodified lines
78struct LookupByIdResult<'a> {78struct LookupByIdResult<'a> {
79 pub file: &'a File,79 pub file: &'a File,
80 pub graph_pos: graph::Position,80 pub graph_pos: graph::Position,
81 pub lex_pos: file::Position,81 pub file_pos: file::Position,
82}82}
83 83
84#[derive(Clone)]84#[derive(Clone)]
85struct LookupByPositionResult<'a> {85struct LookupByPositionResult<'a> {
86 pub file: &'a File,86 pub file: &'a File,
87 pub lex_pos: file::Position,87 pub pos: file::Position,
88}88}