Skip to content

Commit bf9c0cb

Browse files
pks-tgitster
authored andcommitted
revision: stop retrieving reference twice
When queueing up references for the revision walk, `handle_one_ref()` will resolve the reference's object ID via `get_reference()` and then queue the ID as pending object via `add_pending_oid()`. But given that `add_pending_oid()` is only a thin wrapper around `add_pending_object()` which fist calls `get_reference()`, we effectively resolve the reference twice and thus duplicate some of the work. Fix the issue by instead calling `add_pending_object()` directly, which takes the already-resolved object as input. In a repository with lots of refs, this translates into a near 10% speedup: Benchmark #1: HEAD~: rev-list --unsorted-input --objects --quiet --not --all --not $newrev Time (mean ± σ): 5.015 s ± 0.038 s [User: 4.698 s, System: 0.316 s] Range (min … max): 4.970 s … 5.089 s 10 runs Benchmark #2: HEAD: rev-list --unsorted-input --objects --quiet --not --all --not $newrev Time (mean ± σ): 4.606 s ± 0.029 s [User: 4.260 s, System: 0.345 s] Range (min … max): 4.565 s … 4.657 s 10 runs Summary 'HEAD: rev-list --unsorted-input --objects --quiet --not --all --not $newrev' ran 1.09 ± 0.01 times faster than 'HEAD~: rev-list --unsorted-input --objects --quiet --not --all --not $newrev' Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f45022d commit bf9c0cb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

revision.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ static int handle_one_ref(const char *path, const struct object_id *oid,
15341534

15351535
object = get_reference(cb->all_revs, path, oid, cb->all_flags);
15361536
add_rev_cmdline(cb->all_revs, object, path, REV_CMD_REF, cb->all_flags);
1537-
add_pending_oid(cb->all_revs, path, oid, cb->all_flags);
1537+
add_pending_object(cb->all_revs, object, path);
15381538
return 0;
15391539
}
15401540

0 commit comments

Comments
 (0)