summaryrefslogtreecommitdiff
path: root/ws.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 /ws.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 'ws.c')
-rw-r--r--ws.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/ws.c b/ws.c
index b498d7599d..ea4b2b1dfd 100644
--- a/ws.c
+++ b/ws.c
@@ -33,11 +33,8 @@ unsigned parse_whitespace_rule(const char *string)
int negated = 0;
string = string + strspn(string, ", \t\n\r");
- ep = strchr(string, ',');
- if (!ep)
- len = strlen(string);
- else
- len = ep - string;
+ ep = strchrnul(string, ',');
+ len = ep - string;
if (*string == '-') {
negated = 1;