summaryrefslogtreecommitdiff
path: root/diffcore-pickaxe.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-03-22 18:15:59 +0100
committerJunio C Hamano <gitster@pobox.com>2014-03-24 15:13:17 -0700
commit542b2aa2c9afba71febb248edb3083ff9cacf065 (patch)
tree1bc08a524b682127f4502e28a221129d94deb1d8 /diffcore-pickaxe.c
parent3753bd1f69d3b17e0369390fb8960ae3b7855b70 (diff)
downloadgit-542b2aa2c9afba71febb248edb3083ff9cacf065.tar.gz
pickaxe: call strlen only when necessary in diffcore_pickaxe_count()
We need to determine the search term's length only when fixed-string matching is used; regular expression compilation takes a NUL-terminated string directly. Only call strlen() in the former case. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diffcore-pickaxe.c')
-rw-r--r--diffcore-pickaxe.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index 827a7d7e76..70753d058a 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -205,7 +205,6 @@ void diffcore_pickaxe(struct diff_options *o)
{
const char *needle = o->pickaxe;
int opts = o->pickaxe_opts;
- unsigned long len = strlen(needle);
regex_t regex, *regexp = NULL;
kwset_t kws = NULL;
@@ -226,7 +225,7 @@ void diffcore_pickaxe(struct diff_options *o)
} else {
kws = kwsalloc(DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE)
? tolower_trans_tbl : NULL);
- kwsincr(kws, needle, len);
+ kwsincr(kws, needle, strlen(needle));
kwsprep(kws);
}