annotate: remove unneeded commit object lookup

This commit is contained in:
Yuya Nishihara 2024-10-26 21:43:48 +09:00
parent 8249e9fee8
commit 7b9c90d8e6

View file

@ -154,14 +154,13 @@ fn process_commits(
let mut original_line_map = HashMap::new(); let mut original_line_map = HashMap::new();
for node in revset.iter_graph() { for node in revset.iter_graph() {
let (cid, edge_list) = node?; let (commit_id, edge_list) = node?;
let current_commit = repo.store().get_commit(&cid)?;
process_commit( process_commit(
repo, repo,
file_name, file_name,
&mut original_line_map, &mut original_line_map,
&mut commit_source_map, &mut commit_source_map,
&current_commit, &commit_id,
&edge_list, &edge_list,
)?; )?;
if original_line_map.len() >= num_lines { if original_line_map.len() >= num_lines {
@ -186,10 +185,10 @@ fn process_commit(
file_name: &RepoPath, file_name: &RepoPath,
original_line_map: &mut HashMap<usize, CommitId>, original_line_map: &mut HashMap<usize, CommitId>,
commit_source_map: &mut CommitSourceMap, commit_source_map: &mut CommitSourceMap,
current_commit: &Commit, current_commit_id: &CommitId,
edges: &[GraphEdge<CommitId>], edges: &[GraphEdge<CommitId>],
) -> Result<(), BackendError> { ) -> Result<(), BackendError> {
if let Some(mut current_source) = commit_source_map.remove(current_commit.id()) { if let Some(mut current_source) = commit_source_map.remove(current_commit_id) {
for parent_edge in edges { for parent_edge in edges {
if parent_edge.edge_type != GraphEdgeType::Missing { if parent_edge.edge_type != GraphEdgeType::Missing {
let parent_commit_id = &parent_edge.target; let parent_commit_id = &parent_edge.target;
@ -220,7 +219,7 @@ fn process_commit(
if !current_source.line_map.is_empty() { if !current_source.line_map.is_empty() {
mark_lines_from_original( mark_lines_from_original(
original_line_map, original_line_map,
current_commit.id(), current_commit_id,
current_source.line_map, current_source.line_map,
); );
} }