diff options
author | Jeff King <peff@peff.net> | 2017-02-24 16:07:19 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-24 13:22:09 -0800 |
commit | e3394fdce79411fd51e20082c0faf7061007bc1c (patch) | |
tree | 9a0da47c010ef9c915f8759aada1ed82c3d1f27e | |
parent | refs: parse_hide_refs_config to use parse_config_key (diff) | |
download | tgif-e3394fdce79411fd51e20082c0faf7061007bc1c.tar.xz |
parse_config_key: use skip_prefix instead of starts_with
This saves us having to repeatedly add in "section_len" (and
also avoids walking over the first part of the string
multiple times for a strlen() and strrchr()).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | config.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -2531,11 +2531,10 @@ int parse_config_key(const char *var, const char **subsection, int *subsection_len, const char **key) { - int section_len = strlen(section); const char *dot; /* Does it start with "section." ? */ - if (!starts_with(var, section) || var[section_len] != '.') + if (!skip_prefix(var, section, &var) || *var != '.') return -1; /* @@ -2547,12 +2546,12 @@ int parse_config_key(const char *var, *key = dot + 1; /* Did we have a subsection at all? */ - if (dot == var + section_len) { + if (dot == var) { *subsection = NULL; *subsection_len = 0; } else { - *subsection = var + section_len + 1; + *subsection = var + 1; *subsection_len = dot - *subsection; } |