From 2c5495f7b60d6ddcd6a411b48d2f6dbc4a24717a Mon Sep 17 00:00:00 2001 From: Rohit Mani Date: Fri, 7 Mar 2014 22:48:31 -0800 Subject: 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 Signed-off-by: Rohit Mani Signed-off-by: Junio C Hamano --- archive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archive.c') diff --git a/archive.c b/archive.c index 346f3b2f1..d1962157c 100644 --- a/archive.c +++ b/archive.c @@ -259,8 +259,8 @@ static void parse_treeish_arg(const char **argv, /* Remotes are only allowed to fetch actual refs */ if (remote) { char *ref = NULL; - const char *colon = strchr(name, ':'); - int refnamelen = colon ? colon - name : strlen(name); + const char *colon = strchrnul(name, ':'); + int refnamelen = colon - name; if (!dwim_ref(name, refnamelen, sha1, &ref)) die("no such ref: %.*s", refnamelen, name); -- cgit v1.2.1