diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-10-11 14:18:57 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-10-11 14:18:57 -0700 |
commit | 1f253d88face02b68a86fae36e6722c9ebc73856 (patch) | |
tree | 8f644ff0512be5181ccbbc986c8e8fc38d59dbf3 | |
parent | Merge branch 'rs/copy-array' into maint (diff) | |
parent | ref-filter: strip format option after a field name only once while parsing (diff) | |
download | tgif-1f253d88face02b68a86fae36e6722c9ebc73856.tar.xz |
Merge branch 'sg/ref-filter-parse-optim' into maint
The code that parses the format parameter of for-each-ref command
has seen a micro-optimization.
* sg/ref-filter-parse-optim:
ref-filter: strip format option after a field name only once while parsing
-rw-r--r-- | ref-filter.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/ref-filter.c b/ref-filter.c index 9adbb8af3e..9a8f55e45a 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -235,7 +235,7 @@ int parse_ref_filter_atom(const char *atom, const char *ep) { const char *sp; const char *arg; - int i, at; + int i, at, atom_len; sp = atom; if (*sp == '*' && sp < ep) @@ -250,19 +250,19 @@ int parse_ref_filter_atom(const char *atom, const char *ep) return i; } + /* + * If the atom name has a colon, strip it and everything after + * it off - it specifies the format for this entry, and + * shouldn't be used for checking against the valid_atom + * table. + */ + arg = memchr(sp, ':', ep - sp); + atom_len = (arg ? arg : ep) - sp; + /* Is the atom a valid one? */ for (i = 0; i < ARRAY_SIZE(valid_atom); i++) { int len = strlen(valid_atom[i].name); - - /* - * If the atom name has a colon, strip it and everything after - * it off - it specifies the format for this entry, and - * shouldn't be used for checking against the valid_atom - * table. - */ - arg = memchr(sp, ':', ep - sp); - if (len == (arg ? arg : ep) - sp && - !memcmp(valid_atom[i].name, sp, len)) + if (len == atom_len && !memcmp(valid_atom[i].name, sp, len)) break; } |