diff mbox series

[v2,2/3] midx: don't provide a total for QSORT() progress

Message ID patch-v2-2.3-8e67712c48-20210805T105720Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series progress.c API users: fix bogus counting | expand

Commit Message

Ævar Arnfjörð Bjarmason Aug. 5, 2021, 11:01 a.m. UTC
The quicksort algorithm can be anywhere between O(n) and O(n^2), so
providing a "num objects" as a total means that in some cases we're
going to go past 100%.

This fixes a logic error in 5ae18df9d8e (midx: during verify group
objects by packfile to speed verification, 2019-03-21), which in turn
seems to have been diligently copied from my own logic error in the
commit-graph.c code, see 890226ccb57 (commit-graph write: add
itermediate progress, 2019-01-19).

That commit-graph code of mine was removed in
1cbdbf3bef7 (commit-graph: drop count_distinct_commits() function,
2020-12-07), so we don't need to fix that too.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 midx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/midx.c b/midx.c
index 321c6fdd2f..cad78d71fc 100644
--- a/midx.c
+++ b/midx.c
@@ -1292,7 +1292,7 @@  int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
 
 	if (flags & MIDX_PROGRESS)
 		progress = start_sparse_progress(_("Sorting objects by packfile"),
-						 m->num_objects);
+						 0);
 	display_progress(progress, 0); /* TODO: Measure QSORT() progress */
 	QSORT(pairs, m->num_objects, compare_pair_pos_vs_id);
 	stop_progress(&progress);