Skip to content

Commit 542b2aa

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3753bd1 commit 542b2aa

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

diffcore-pickaxe.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ void diffcore_pickaxe(struct diff_options *o)
205205
{
206206
const char *needle = o->pickaxe;
207207
int opts = o->pickaxe_opts;
208-
unsigned long len = strlen(needle);
209208
regex_t regex, *regexp = NULL;
210209
kwset_t kws = NULL;
211210

@@ -226,7 +225,7 @@ void diffcore_pickaxe(struct diff_options *o)
226225
} else {
227226
kws = kwsalloc(DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE)
228227
? tolower_trans_tbl : NULL);
229-
kwsincr(kws, needle, len);
228+
kwsincr(kws, needle, strlen(needle));
230229
kwsprep(kws);
231230
}
232231

0 commit comments

Comments
 (0)