зеркало из https://github.com/microsoft/git.git
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
This commit is contained in:
Коммит
1f253d88fa
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 *arg;
|
||||
int i, at;
|
||||
int i, at, atom_len;
|
||||
|
||||
sp = atom;
|
||||
if (*sp == '*' && sp < ep)
|
||||
|
@ -250,10 +250,6 @@ int parse_ref_filter_atom(const char *atom, const char *ep)
|
|||
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
|
||||
* 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.
|
||||
*/
|
||||
arg = memchr(sp, ':', ep - sp);
|
||||
if (len == (arg ? arg : ep) - sp &&
|
||||
!memcmp(valid_atom[i].name, sp, len))
|
||||
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 (len == atom_len && !memcmp(valid_atom[i].name, sp, len))
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче