fetch-pack: use DEFINE_LIST_SORT

Build a static typed ref sorting function using DEFINE_LIST_SORT along
with a typed comparison function near its only two callers instead of
having an exported version that calls llist_mergesort().  This gets rid
of the next pointer accessor functions and their calling overhead at the
cost of a slightly increased object text size.

Before:
__TEXT	__DATA	__OBJC	others	dec	hex
23231	389	0	113689	137309	2185d	fetch-pack.o
29158	80	0	146864	176102	2afe6	remote.o

With this patch:
__TEXT	__DATA	__OBJC	others	dec	hex
23591	389	0	117759	141739	229ab	fetch-pack.o
29070	80	0	145718	174868	2ab14	remote.o

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2022-07-16 18:59:59 +02:00
committed by Junio C Hamano
parent c0fb5774a6
commit 6fc9fec07b
3 changed files with 8 additions and 24 deletions

View File

@ -26,6 +26,7 @@
#include "commit-reach.h"
#include "commit-graph.h"
#include "sigchain.h"
#include "mergesort.h"
static int transfer_unpack_limit = -1;
static int fetch_unpack_limit = -1;
@ -1010,6 +1011,13 @@ static int get_pack(struct fetch_pack_args *args,
return 0;
}
static int ref_compare_name(const struct ref *a, const struct ref *b)
{
return strcmp(a->name, b->name);
}
DEFINE_LIST_SORT(static, sort_ref_list, struct ref, next);
static int cmp_ref_by_name(const void *a_, const void *b_)
{
const struct ref *a = *((const struct ref **)a_);