* [PATCH] make sha1_sort inline
@ 2006-08-18 5:30 David Rientjes
2006-08-18 5:43 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2006-08-18 5:30 UTC (permalink / raw)
To: git
Inlines sha1_sort as discussed in previous thread.
Signed-off-by: David Rientjes <rientjes@google.com>
---
builtin-pack-objects.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index f19f0d6..b7ba558 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -929,7 +929,8 @@ static struct object_entry **create_sort
return list;
}
-static int sha1_sort(const struct object_entry *a, const struct object_entry *b)
+static inline int sha1_sort(const struct object_entry *a,
+ const struct object_entry *b)
{
return hashcmp(a->sha1, b->sha1);
}
--
1.4.2.rc4.gd070-dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] make sha1_sort inline
2006-08-18 5:30 [PATCH] make sha1_sort inline David Rientjes
@ 2006-08-18 5:43 ` Junio C Hamano
2006-08-18 16:56 ` David Rientjes
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2006-08-18 5:43 UTC (permalink / raw)
To: David Rientjes; +Cc: git
David Rientjes <rientjes@google.com> writes:
> Inlines sha1_sort as discussed in previous thread.
The only use of this function is to got its address taken of,
and then the variable that has its address (current_sort) is
used by sort_comparator() function, whose address is given to
the library routine qsort(3).
Does it still make sense to declare it inline?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] make sha1_sort inline
2006-08-18 5:43 ` Junio C Hamano
@ 2006-08-18 16:56 ` David Rientjes
0 siblings, 0 replies; 3+ messages in thread
From: David Rientjes @ 2006-08-18 16:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Thu, 17 Aug 2006, Junio C Hamano wrote:
> The only use of this function is to got its address taken of,
> and then the variable that has its address (current_sort) is
> used by sort_comparator() function, whose address is given to
> the library routine qsort(3).
>
> Does it still make sense to declare it inline?
>
>
No.
Well, maybe just "not yet." The idea is to isolate the sort functions for
hashes since we may add support for additional ones in the future (re: my
thread on md5). Then all these functions would probably be abstracted to
a single file and labeled as static with a single global function:
static int hash_sort(const struct object_entry,
const struct object_entry);
which would call the static inline function that corresponds to the hash
in use for that database. This can't simply be #ifdef's since the choice
of hash would not be compile-time, it would be run-time depending on what
flags are sent during init-db.
And instead of:
struct object_entry {
unsigned char sha1[20];
...
}
it becomes:
struct object_entry {
union hash_name {
unsigned char sha1[20];
...
}
...
}
So in that case, the static inline of the sort does have its advantage as
opposed to two function calls on any hash_sort. But I agree in the
meantime while additional hashes are still be considered that this would
not be an advantageous addition to the code.
(At least you get an idea of what I'm thinking about hashes)
David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-08-18 16:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-18 5:30 [PATCH] make sha1_sort inline David Rientjes
2006-08-18 5:43 ` Junio C Hamano
2006-08-18 16:56 ` David Rientjes
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 NNTP newsgroup(s).