Skip to content

Commit e944d9d

Browse files
pcloudsgitster
authored andcommitted
grep: rewrite an if/else condition to avoid duplicate expression
"!icase || ascii_only" is repeated twice in this if/else chain as this series evolves. Rewrite it (and basically revert the first if condition back to before the "grep: break down an "if" stmt..." commit). Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 793dc67 commit e944d9d

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

grep.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,8 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
442442
* simple string match using kws. p->fixed tells us if we
443443
* want to use kws.
444444
*/
445-
if (opt->fixed)
445+
if (opt->fixed || is_fixed(p->pattern, p->patternlen))
446446
p->fixed = !icase || ascii_only;
447-
else if ((!icase || ascii_only) &&
448-
is_fixed(p->pattern, p->patternlen))
449-
p->fixed = 1;
450447
else
451448
p->fixed = 0;
452449

0 commit comments

Comments
 (0)