Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-09 Thread René Scharfe
Am 07.10.2014 um 20:23 schrieb Junio C Hamano: René Scharfe l@web.de writes: @@ -335,20 +337,18 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags, static struct { int kind; const char *prefix; -int pfxlen;

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-09 Thread Junio C Hamano
René Scharfe l@web.de writes: I didn't think much about the performance implications. skip_prefix() doesn't call strlen(3), though. Ah, OK. The code handles millions of ref strings per second before and after the change, and with the change it's faster. I hope the results are

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-07 Thread Junio C Hamano
Jeff King p...@peff.net writes: On Sun, Oct 05, 2014 at 03:49:19PM -0700, Jonathan Nieder wrote: --- a/builtin/branch.c +++ b/builtin/branch.c @@ -81,14 +81,16 @@ static int parse_branch_color_slot(const char *var, int ofs) static int git_branch_config(const char *var, const

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-07 Thread Junio C Hamano
Jeff King p...@peff.net writes: On Sun, Oct 05, 2014 at 03:49:19PM -0700, Jonathan Nieder wrote: --- a/builtin/branch.c +++ b/builtin/branch.c @@ -81,14 +81,16 @@ static int parse_branch_color_slot(const char *var, int ofs) static int git_branch_config(const char *var, const

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-07 Thread Junio C Hamano
René Scharfe l@web.de writes: @@ -335,20 +337,18 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags, static struct { int kind; const char *prefix; - int pfxlen; } ref_kind[] = { - {

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-07 Thread Jeff King
On Tue, Oct 07, 2014 at 11:21:58AM -0700, Junio C Hamano wrote: The fix you proposed below is along the same line, and looks good to me (and grepping for 'var *+ *ofs' shows only the two sites you found, so hopefully that is the last of it). builtin/commit.c::parse_status_slot() has the

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-07 Thread Jeff King
On Tue, Oct 07, 2014 at 11:14:35AM -0700, Junio C Hamano wrote: The fix you proposed below is along the same line, and looks good to me (and grepping for 'var *+ *ofs' shows only the two sites you found, so hopefully that is the last of it). So perhaps we would want this change as a

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-07 Thread Jeff King
On Tue, Oct 07, 2014 at 03:16:56PM -0400, Jeff King wrote: Actually, parse_decorate_color_config is slightly odd in that it takes the variable and the slot_name after this patch. That's because it passes the full variable name to color_parse, which does still die() on error. Perhaps it should

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-07 Thread Junio C Hamano
Jeff King p...@peff.net writes: Subject: color_parse: do not mention variable name in error message ... I think the two-line errors are kind of ugly. It does match how config_error_nonbool works, which also propagates its errors, and looks like: $ git -c color.branch.plain branch

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-05 Thread Jonathan Nieder
René Scharfe wrote: Continue where ae021d87 (use skip_prefix to avoid magic numbers) left off and use skip_prefix() in more places for determining the lengths of prefix strings to avoid using dependent constants and other indirect methods. Sounds promising. [...] --- a/builtin/branch.c +++

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-05 Thread Jeff King
On Sun, Oct 05, 2014 at 03:49:19PM -0700, Jonathan Nieder wrote: --- a/builtin/branch.c +++ b/builtin/branch.c @@ -81,14 +81,16 @@ static int parse_branch_color_slot(const char *var, int ofs) static int git_branch_config(const char *var, const char *value, void *cb) { +

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-05 Thread Jeff King
On Sat, Oct 04, 2014 at 08:54:50PM +0200, René Scharfe wrote: Continue where ae021d87 (use skip_prefix to avoid magic numbers) left off and use skip_prefix() in more places for determining the lengths of prefix strings to avoid using dependent constants and other indirect methods. Thanks,

[PATCH] use skip_prefix() to avoid more magic numbers

2014-10-04 Thread René Scharfe
Continue where ae021d87 (use skip_prefix to avoid magic numbers) left off and use skip_prefix() in more places for determining the lengths of prefix strings to avoid using dependent constants and other indirect methods. Signed-off-by: Rene Scharfe l@web.de --- builtin/apply.c |