# \[PATCH v2 06/12\] grep: rewrite an if/else condition to avoid duplicate expression

- From: Nguyễn Thái Ngọc Duy \<hidden\>
- Date: 2016-06-25 05:24:30 
- List: git
- Page: https://ratatoskr.run/git/2016/06/7684295
- Thread: https://ratatoskr.run/git/2016/06/7684151/t.md

```text
"!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 [ref]
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
 grep.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/grep.c b/grep.c
index 5a8c52a..4b6b7bc 100644
--- a/grep.c
+++ b/grep.c
@@ -426,11 +426,8 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
 	icase	       = opt->regflags & REG_ICASE || p->ignore_case;
 	ascii_only     = !has_non_ascii(p->pattern);
 
-	if (opt->fixed)
+	if (opt->fixed || is_fixed(p->pattern, p->patternlen))
 		p->fixed = !icase || ascii_only;
-	else if ((!icase || ascii_only) &&
-		 is_fixed(p->pattern, p->patternlen))
-		p->fixed = 1;
 	else
 		p->fixed = 0;
 
-- 
2.8.2.526.g02eed6d

```
