From 2971c45e04ab585f2f604fbbf73a99b2f152e01c Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 29 Jan 2023 10:20:48 -0800 Subject: [PATCH] index_store: don't look up whole commit when only id is needed When building an initial index from an existing Git repo, for example, we walk parents and predecessors to find all commits to index. Part of that code was looking up the whole parent and predecessor commits even though it only needed the ids. I don't know if this has a measurable impact on performance, but it's not really any more complex to just get the ids anyway. --- lib/src/index_store.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/src/index_store.rs b/lib/src/index_store.rs index 249af3261..147824374 100644 --- a/lib/src/index_store.rs +++ b/lib/src/index_store.rs @@ -214,10 +214,14 @@ fn topo_order_earlier_first( let mut visited = in_parent_file; while let Some(commit) = commits.pop() { let mut waiting_for_earlier_commit = false; - for earlier in commit.parents().iter().chain(commit.predecessors().iter()) { - if !visited.contains(earlier.id()) { + for earlier in commit + .parent_ids() + .iter() + .chain(commit.predecessor_ids().iter()) + { + if !visited.contains(earlier) { waiting - .entry(earlier.id().clone()) + .entry(earlier.clone()) .or_insert_with(Vec::new) .push(commit.clone()); waiting_for_earlier_commit = true;