ref-filter: strip format option after a field name only once while parsing
When parse_ref_filter_atom() iterates over a list of valid atoms to check that a field name is one of them, it has to strip the optional colon-separated format option suffix that might follow the field name. However, it does so inside the loop, i.e. it performs the exact same stripping over and over again. Move stripping the format option suffix out of that loop, so it's only performed once for each parsed field name. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
92d426662b
commit
e94ce1394e
14
ref-filter.c
14
ref-filter.c
@ -235,7 +235,7 @@ int parse_ref_filter_atom(const char *atom, const char *ep)
|
|||||||
{
|
{
|
||||||
const char *sp;
|
const char *sp;
|
||||||
const char *arg;
|
const char *arg;
|
||||||
int i, at;
|
int i, at, atom_len;
|
||||||
|
|
||||||
sp = atom;
|
sp = atom;
|
||||||
if (*sp == '*' && sp < ep)
|
if (*sp == '*' && sp < ep)
|
||||||
@ -250,10 +250,6 @@ int parse_ref_filter_atom(const char *atom, const char *ep)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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
|
* If the atom name has a colon, strip it and everything after
|
||||||
* it off - it specifies the format for this entry, and
|
* it off - it specifies the format for this entry, and
|
||||||
@ -261,8 +257,12 @@ int parse_ref_filter_atom(const char *atom, const char *ep)
|
|||||||
* table.
|
* table.
|
||||||
*/
|
*/
|
||||||
arg = memchr(sp, ':', ep - sp);
|
arg = memchr(sp, ':', ep - sp);
|
||||||
if (len == (arg ? arg : ep) - sp &&
|
atom_len = (arg ? arg : ep) - sp;
|
||||||
!memcmp(valid_atom[i].name, sp, len))
|
|
||||||
|
/* Is the atom a valid one? */
|
||||||
|
for (i = 0; i < ARRAY_SIZE(valid_atom); i++) {
|
||||||
|
int len = strlen(valid_atom[i].name);
|
||||||
|
if (len == atom_len && !memcmp(valid_atom[i].name, sp, len))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user