Skip to content

Commit 8fe8bae

Browse files
avargitster
authored andcommitted
pack-write: skip *.rev work when not writing *.rev
Fix a performance regression introduced in a587b5a (pack-write.c: extract 'write_rev_file_order', 2021-03-30) and stop needlessly allocating the "pack_order" array and sorting it with "pack_order_cmp()", only to throw that work away when we discover that we're not writing *.rev files after all. This redundant work was not present in the original version of this code added in 8ef50d9 (pack-write.c: prepare to write 'pack-*.rev' files, 2021-01-25). There we'd call write_rev_file() from e.g. finish_tmp_packfile(), but we'd "return NULL" early in write_rev_file() if not doing a "WRITE_REV" or "WRITE_REV_VERIFY". Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebf3c04 commit 8fe8bae

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pack-write.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ const char *write_rev_file(const char *rev_name,
224224
uint32_t i;
225225
const char *ret;
226226

227+
if (!(flags & WRITE_REV) && !(flags & WRITE_REV_VERIFY))
228+
return NULL;
229+
227230
ALLOC_ARRAY(pack_order, nr_objects);
228231
for (i = 0; i < nr_objects; i++)
229232
pack_order[i] = i;

0 commit comments

Comments
 (0)