From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 09/10] packfile: use DEFINE_LIST_SORT
Date: Sat, 16 Jul 2022 19:01:18 +0200 [thread overview]
Message-ID: <a041739a-cf0c-ac8d-c8ec-5c046575f59a@web.de> (raw)
In-Reply-To: <4d7cd286-398e-215c-f2bd-aa7e8207be4f@web.de>
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>
---
packfile.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/packfile.c b/packfile.c
index ed69fe457b..6b0eb9048e 100644
--- a/packfile.c
+++ b/packfile.c
@@ -941,20 +941,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;
/*
@@ -981,9 +971,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)
--
2.37.1
next prev parent reply other threads:[~2022-07-16 17:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-16 16:50 [PATCH 00/10] typed sort of linked lists René Scharfe
2022-07-16 16:52 ` [PATCH 01/10] mergesort: unify ranks loops René Scharfe
2022-07-16 16:53 ` [PATCH 02/10] mergesort: tighten merge loop René Scharfe
2022-07-16 16:54 ` [PATCH 03/10] mergesort: add macros for typed sort of linked lists René Scharfe
2022-07-16 16:56 ` [PATCH 04/10] test-mergesort: use DEFINE_LIST_SORT_DEBUG René Scharfe
2022-07-16 16:57 ` [PATCH 05/10] test-mergesort: use DEFINE_LIST_SORT René Scharfe
2022-07-16 16:58 ` [PATCH 06/10] blame: " René Scharfe
2022-07-16 16:59 ` [PATCH 07/10] commit: " René Scharfe
2022-07-16 16:59 ` [PATCH 08/10] fetch-pack: " René Scharfe
2022-07-16 17:01 ` René Scharfe [this message]
2022-07-16 17:02 ` [PATCH 10/10] mergesort: remove llist_mergesort() René Scharfe
2022-07-17 22:31 ` [PATCH 00/10] typed sort of linked lists Junio C Hamano
2022-07-25 18:52 ` Junio C Hamano
2022-07-25 20:35 ` Derrick Stolee
2022-07-25 20:49 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a041739a-cf0c-ac8d-c8ec-5c046575f59a@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).