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>

René Scharfe committed Mar 22, 2014 at 18:15 UTC 542b2aa2c9afba71febb248edb3083ff9cacf065
1 file changed +1 -2
diffcore-pickaxe.c
+1 -2
@@ -205,7 +205,6 @@ void diffcore_pickaxe(struct diff_options *o)
205 {
206 const char *needle = o->pickaxe;
207 int opts = o->pickaxe_opts;
208 - unsigned long len = strlen(needle);
208 regex_t regex, *regexp = NULL;
209 kwset_t kws = NULL;
210
@@ -226,7 +225,7 @@ void diffcore_pickaxe(struct diff_options *o)
225 } else {
226 kws = kwsalloc(DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE)
227 ? tolower_trans_tbl : NULL);
229 - kwsincr(kws, needle, len);
228 + kwsincr(kws, needle, strlen(needle));
229 kwsprep(kws);
230 }
231