{"thread":{"id":"5315","subject":"[PATCH] make sha1_sort inline","startedAt":"2006-08-18T05:30:46Z","lastAt":"2006-08-18T16:56:01Z","messageCount":3,"participants":["David Rientjes","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"25523","messageId":"Pine.LNX.4.63.0608172229070.25827@chino.corp.google.com","threadId":"5315","inReplyTo":null,"subject":"[PATCH] make sha1_sort inline","fromName":"David Rientjes","fromEmail":"rientjes@google.com","sentAt":"2006-08-18T05:30:46Z","receivedAt":"2006-08-18T05:30:46Z","isPatch":true,"sender":{"key":"rientjes@google.com","avatar":null},"body":"Inlines sha1_sort as discussed in previous thread.\n\nSigned-off-by: David Rientjes <rientjes@google.com>\n---\n builtin-pack-objects.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex f19f0d6..b7ba558 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -929,7 +929,8 @@ static struct object_entry **create_sort\n \treturn list;\n }\n \n-static int sha1_sort(const struct object_entry *a, const struct object_entry *b)\n+static inline int sha1_sort(const struct object_entry *a,\n+\t\t\t    const struct object_entry *b)\n {\n \treturn hashcmp(a->sha1, b->sha1);\n }\n-- \n1.4.2.rc4.gd070-dirty\n"},{"id":"25524","messageId":"7vsljud2fs.fsf@assigned-by-dhcp.cox.net","threadId":"5315","inReplyTo":"Pine.LNX.4.63.0608172229070.25827@chino.corp.google.com","subject":"Re: [PATCH] make sha1_sort inline","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-18T05:43:03Z","receivedAt":"2006-08-18T05:43:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Rientjes <rientjes@google.com> writes:\n\n> Inlines sha1_sort as discussed in previous thread.\n\nThe only use of this function is to got its address taken of,\nand then the variable that has its address (current_sort) is\nused by sort_comparator() function, whose address is given to\nthe library routine qsort(3).\n\nDoes it still make sense to declare it inline?\n"},{"id":"25572","messageId":"Pine.LNX.4.63.0608180947240.29405@chino.corp.google.com","threadId":"5315","inReplyTo":"7vsljud2fs.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] make sha1_sort inline","fromName":"David Rientjes","fromEmail":"rientjes@google.com","sentAt":"2006-08-18T16:56:01Z","receivedAt":"2006-08-18T16:56:01Z","isPatch":true,"sender":{"key":"rientjes@google.com","avatar":null},"body":"On Thu, 17 Aug 2006, Junio C Hamano wrote:\n\n> The only use of this function is to got its address taken of,\n> and then the variable that has its address (current_sort) is\n> used by sort_comparator() function, whose address is given to\n> the library routine qsort(3).\n> \n> Does it still make sense to declare it inline?\n> \n> \n\nNo.\n\nWell, maybe just \"not yet.\"  The idea is to isolate the sort functions for \nhashes since we may add support for additional ones in the future (re: my \nthread on md5).  Then all these functions would probably be abstracted to \na single file and labeled as static with a single global function:\n\n\tstatic int hash_sort(const struct object_entry,\n\t\t\t     const struct object_entry);\n\nwhich would call the static inline function that corresponds to the hash \nin use for that database.  This can't simply be #ifdef's since the choice \nof hash would not be compile-time, it would be run-time depending on what \nflags are sent during init-db.\n\nAnd instead of:\n\tstruct object_entry {\n\t\tunsigned char sha1[20];\n\t\t...\n\t}\n\nit becomes:\n\tstruct object_entry {\n\t\tunion hash_name {\n\t\t\tunsigned char sha1[20];\n\t\t\t...\n\t\t}\n\t\t...\n\t}\n\nSo in that case, the static inline of the sort does have its advantage as \nopposed to two function calls on any hash_sort.  But I agree in the \nmeantime while additional hashes are still be considered that this would \nnot be an advantageous addition to the code.\n\n(At least you get an idea of what I'm thinking about hashes)\n\n\t\tDavid\n"}]}