diff options
author | Rohit Mani <rohit.mani@outlook.com> | 2014-03-08 07:48:31 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-03-10 16:35:30 +0100 |
commit | 2c5495f7b60d6ddcd6a411b48d2f6dbc4a24717a (patch) | |
tree | 9900454e2b547e2fee8e9e67b39ced68ea0c650e /diff.c | |
parent | Git 1.9.0 (diff) | |
download | git-2c5495f7b60d6ddcd6a411b48d2f6dbc4a24717a.tar.xz git-2c5495f7b60d6ddcd6a411b48d2f6dbc4a24717a.zip |
use strchrnul() in place of strchr() and 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 'diff.c')
-rw-r--r-- | diff.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -3365,14 +3365,11 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va if (c != '-') return 0; arg++; - eq = strchr(arg, '='); - if (eq) - len = eq - arg; - else - len = strlen(arg); + eq = strchrnul(arg, '='); + len = eq - arg; if (!len || strncmp(arg, arg_long, len)) return 0; - if (eq) { + if (*eq) { int n; char *end; if (!isdigit(*++eq)) |