Skip to content

Commit ae807d7

Browse files
avargitster
authored andcommitted
grep.c: do "if (bool && memchr())" not "if (memchr() && bool)"
Change code in compile_regexp() to check the cheaper boolean "!opt->pcre2" condition before the "memchr()" search. This doesn't noticeably optimize anything, but makes the code more obvious and conventional. The line wrapping being added here also makes a subsequent commit smaller. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 321ee43 commit ae807d7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

grep.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
492492
p->ignore_case = opt->ignore_case;
493493
p->fixed = opt->fixed;
494494

495-
if (memchr(p->pattern, 0, p->patternlen) && !opt->pcre2)
495+
if (!opt->pcre2 &&
496+
memchr(p->pattern, 0, p->patternlen))
496497
die(_("given pattern contains NULL byte (via -f <file>). This is only supported with -P under PCRE v2"));
497498

498499
p->is_fixed = is_fixed(p->pattern, p->patternlen);

0 commit comments

Comments
 (0)