summaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorRohit Mani <rohit.mani@outlook.com>2014-03-07 22:48:31 -0800
committerJunio C Hamano <gitster@pobox.com>2014-03-10 08:35:30 -0700
commit2c5495f7b60d6ddcd6a411b48d2f6dbc4a24717a (patch)
tree9900454e2b547e2fee8e9e67b39ced68ea0c650e /parse-options.c
parent5f95c9f850b19b368c43ae399cc831b17a26a5ac (diff)
downloadgit-2c5495f7b60d6ddcd6a411b48d2f6dbc4a24717a.tar.gz
use strchrnul() in place of strchr() and strlen()rm/strchrnul-not-strlen
Avoid scanning strings twice, once with strchr() and then with strlen(), by using strchrnul(). Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Rohit Mani <rohit.mani@outlook.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/parse-options.c b/parse-options.c
index 7b8d3faa17..a5fa0b8938 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -223,13 +223,10 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
const struct option *options)
{
const struct option *all_opts = options;
- const char *arg_end = strchr(arg, '=');
+ const char *arg_end = strchrnul(arg, '=');
const struct option *abbrev_option = NULL, *ambiguous_option = NULL;
int abbrev_flags = 0, ambiguous_flags = 0;
- if (!arg_end)
- arg_end = arg + strlen(arg);
-
for (; options->type != OPTION_END; options++) {
const char *rest, *long_name = options->long_name;
int flags = 0, opt_flags = 0;