Re: [PATCH] builtins: search builtin commands via binary search.

2013-07-29 Thread Junio C Hamano
Stefan Beller stefanbel...@googlemail.com writes: However I could not find a speedup. So if the patch is accepted, it would only be for readability. This adds a maintenance burden. It is very easy for somebody to mistakenly run sort on the region in her editor under non C locale. Perhaps

Re: [PATCH] builtins: search builtin commands via binary search.

2013-07-27 Thread Stefan Beller
On 07/26/2013 10:57 PM, Jonathan Nieder wrote: Hi, Stefan Beller wrote: --- a/git.c +++ b/git.c @@ -309,9 +309,18 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) return 0; } +static int compare_internal_command(const void *a, const void *b) { +

[PATCH] builtins: search builtin commands via binary search.

2013-07-27 Thread Stefan Beller
There are currently 115 commands built into the git executable. Before this commit, it was iterated over these commands in a linear order, i.e. each command was checked. As it turns out the commands are already sorted alphabetically, it is easy to perform a binary search instead of linear

Re: [PATCH] builtins: search builtin commands via binary search.

2013-07-27 Thread Andreas Schwab
Stefan Beller stefanbel...@googlemail.com writes: My approach would have been: sorted_internal_cmds: git.c { awk '/cmd_struct commands/,/};/ { if (match($2,//)) print $2 }' git.c builtin.actual \ sort builtin.actual builtin.expect \ cmp -s builtin.expect builtin.actual

[PATCH] builtins: search builtin commands via binary search.

2013-07-26 Thread Stefan Beller
There are currently 115 commands built into the git executable. Before this commit, it was iterated over these commands in a linear order, i.e. each command was checked. As it turns out the commands are already sorted alphabetically, it is easy to perform a binary search instead of linear

Re: [PATCH] builtins: search builtin commands via binary search.

2013-07-26 Thread Jonathan Nieder
Hi, Stefan Beller wrote: --- a/git.c +++ b/git.c @@ -309,9 +309,18 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) return 0; } +static int compare_internal_command(const void *a, const void *b) { + /* The first parameter is of type char*

Re: [PATCH] builtins: search builtin commands via binary search.

2013-07-26 Thread Eric Sunshine
On Fri, Jul 26, 2013 at 4:50 PM, Stefan Beller stefanbel...@googlemail.com wrote: There are currently 115 commands built into the git executable. Before this commit, it was iterated over these commands in a linear order, i.e. each command was checked. As it turns out the commands are already