Skip to content

Commit 9b9f5f6

Browse files
rscharfegitster
authored andcommitted
packfile: use DEFINE_LIST_SORT
Build a typed sort function for packed_git lists using DEFINE_LIST_SORT instead of calling llist_mergesort(). This gets rid of the next pointer accessor functions and their calling overhead at the cost of slightly increased object text size. Before: __TEXT __DATA __OBJC others dec hex 20218 320 0 110936 131474 20192 packfile.o With this patch: __TEXT __DATA __OBJC others dec hex 20430 320 0 112619 133369 208f9 packfile.o Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6fc9fec commit 9b9f5f6

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

packfile.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -926,20 +926,10 @@ unsigned long repo_approximate_object_count(struct repository *r)
926926
return r->objects->approximate_object_count;
927927
}
928928

929-
static void *get_next_packed_git(const void *p)
930-
{
931-
return ((const struct packed_git *)p)->next;
932-
}
933-
934-
static void set_next_packed_git(void *p, void *next)
935-
{
936-
((struct packed_git *)p)->next = next;
937-
}
929+
DEFINE_LIST_SORT(static, sort_packs, struct packed_git, next);
938930

939-
static int sort_pack(const void *a_, const void *b_)
931+
static int sort_pack(const struct packed_git *a, const struct packed_git *b)
940932
{
941-
const struct packed_git *a = a_;
942-
const struct packed_git *b = b_;
943933
int st;
944934

945935
/*
@@ -966,9 +956,7 @@ static int sort_pack(const void *a_, const void *b_)
966956

967957
static void rearrange_packed_git(struct repository *r)
968958
{
969-
r->objects->packed_git = llist_mergesort(
970-
r->objects->packed_git, get_next_packed_git,
971-
set_next_packed_git, sort_pack);
959+
sort_packs(&r->objects->packed_git, sort_pack);
972960
}
973961

974962
static void prepare_packed_git_mru(struct repository *r)

0 commit comments

Comments
 (0)