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.
This commit is contained in:
Martin von Zweigbergk 2023-01-29 10:20:48 -08:00 committed by Martin von Zweigbergk
parent be638d0205
commit 2971c45e04

View file

@ -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;