summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8cc3fe4)
raw | patch | inline | side by side (parent: 8cc3fe4)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sat, 7 Mar 2009 12:27:15 +0000 (13:27 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 7 Mar 2009 19:34:53 +0000 (11:34 -0800) |
In addition to returning if an expression matches a line,
match_expr_eval() updates the expression's hit flag if the parameter
collect_hits is set. It never sets collect_hits for children of AND
nodes, though, so their hit flag will never be updated. Because of
that we can return early if the first child didn't match, no matter
if collect_hits is set or not.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
match_expr_eval() updates the expression's hit flag if the parameter
collect_hits is set. It never sets collect_hits for children of AND
nodes, though, so their hit flag will never be updated. Because of
that we can return early if the first child didn't match, no matter
if collect_hits is set or not.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c | patch | blob | history |
index 062b2b6f28f6332518240d2a474a7739735e1ecf..db341b6797ccb5e44796ff1556437677f595a913 100644 (file)
--- a/grep.c
+++ b/grep.c
h = !match_expr_eval(o, x->u.unary, bol, eol, ctx, 0);
break;
case GREP_NODE_AND:
- if (!collect_hits)
- return (match_expr_eval(o, x->u.binary.left,
- bol, eol, ctx, 0) &&
- match_expr_eval(o, x->u.binary.right,
- bol, eol, ctx, 0));
- h = match_expr_eval(o, x->u.binary.left, bol, eol, ctx, 0);
- h &= match_expr_eval(o, x->u.binary.right, bol, eol, ctx, 0);
+ if (!match_expr_eval(o, x->u.binary.left, bol, eol, ctx, 0))
+ return 0;
+ h = match_expr_eval(o, x->u.binary.right, bol, eol, ctx, 0);
break;
case GREP_NODE_OR:
if (!collect_hits)