Thread (26 messages) flat view 26 messages, 2 authors, 2016-06-25
STALE3740d

Revision v2 of 3 in this series.

Revisions (3)
  1. v7 [diff vs current]
  2. v1 [diff vs current]
  3. v2 current

[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
Subsystem: the rest · Maintainer: Linus Torvalds

"!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 [off-list 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help