Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2022-07-16 20:01:18 +0300
committerJunio C Hamano <gitster@pobox.com>2022-07-18 01:20:39 +0300
commit9b9f5f6217a5178e348dc2e18bc6af7158b97c36 (patch)
treea5593fdd08bf48a20a146adf69c3f62f26fec994 /packfile.c
parent6fc9fec07bcaa6561aff5b485f1ac581f97a2428 (diff)
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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.c')
-rw-r--r--packfile.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/packfile.c b/packfile.c
index 835b2d2716..dc7cd7b20b 100644
--- a/packfile.c
+++ b/packfile.c
@@ -926,20 +926,10 @@ unsigned long repo_approximate_object_count(struct repository *r)
return r->objects->approximate_object_count;
}
-static void *get_next_packed_git(const void *p)
-{
- return ((const struct packed_git *)p)->next;
-}
-
-static void set_next_packed_git(void *p, void *next)
-{
- ((struct packed_git *)p)->next = next;
-}
+DEFINE_LIST_SORT(static, sort_packs, struct packed_git, next);
-static int sort_pack(const void *a_, const void *b_)
+static int sort_pack(const struct packed_git *a, const struct packed_git *b)
{
- const struct packed_git *a = a_;
- const struct packed_git *b = b_;
int st;
/*
@@ -966,9 +956,7 @@ static int sort_pack(const void *a_, const void *b_)
static void rearrange_packed_git(struct repository *r)
{
- r->objects->packed_git = llist_mergesort(
- r->objects->packed_git, get_next_packed_git,
- set_next_packed_git, sort_pack);
+ sort_packs(&r->objects->packed_git, sort_pack);
}
static void prepare_packed_git_mru(struct repository *r)