Skip to content

Commit f463beb

Browse files
avargitster
authored andcommitted
grep: inline the return value of a function call used only once
Since e944d9d ("grep: rewrite an if/else condition to avoid duplicate expression", 2016-06-25) the "ascii_only" variable has only been used once in compile_regexp(), let's just inline it there. This makes the code easier to read, and might make it marginally faster depending on compiler optimizations. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b14cf11 commit f463beb

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

grep.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,13 +650,11 @@ static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)
650650

651651
static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
652652
{
653-
int ascii_only;
654653
int err;
655654
int regflags = REG_NEWLINE;
656655

657656
p->word_regexp = opt->word_regexp;
658657
p->ignore_case = opt->ignore_case;
659-
ascii_only = !has_non_ascii(p->pattern);
660658

661659
/*
662660
* Even when -F (fixed) asks us to do a non-regexp search, we
@@ -673,7 +671,7 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
673671
if (opt->fixed ||
674672
has_null(p->pattern, p->patternlen) ||
675673
is_fixed(p->pattern, p->patternlen))
676-
p->fixed = !p->ignore_case || ascii_only;
674+
p->fixed = !p->ignore_case || !has_non_ascii(p->pattern);
677675

678676
if (p->fixed) {
679677
p->kws = kwsalloc(p->ignore_case ? tolower_trans_tbl : NULL);

0 commit comments

Comments
 (0)