summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-06-25 07:22:32 +0200
committerJunio C Hamano <gitster@pobox.com>2016-07-01 12:44:57 -0700
commite944d9d932b3653debcfdd16eec2721eed0670e5 (patch)
tree0477bcb979253c7ae0038267b61553278317a0f2 /grep.c
parent793dc676e08394ed15bffe0ed66606ff9ced1c6a (diff)
downloadgit-e944d9d932b3653debcfdd16eec2721eed0670e5.tar.gz
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 <gitster@pobox.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/grep.c b/grep.c
index 627ae3e3e8..6325cafe73 100644
--- a/grep.c
+++ b/grep.c
@@ -442,11 +442,8 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
* simple string match using kws. p->fixed tells us if we
* want to use kws.
*/
- 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;