Subject: Re: [PATCH v6 02/11] grep: break down an "if" stmt in preparation for next changes

From: Junio C Hamano <[email-masked]>
Date: Tue, 09 Feb 2016 10:20:04 -0800

Nguyễn Thái Ngọc Duy  <[email-masked]> writes:

> Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
> ---
>  grep.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/grep.c b/grep.c
> index 7b2b96a..e739d20 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -403,9 +403,11 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
>  	p->word_regexp = opt->word_regexp;
>  	p->ignore_case = opt->ignore_case;
>  
> -	if (opt->fixed || is_fixed(p->pattern, p->patternlen))
> +	if (is_fixed(p->pattern, p->patternlen))
>  		p->fixed = 1;
> -	else
> +	else if (opt->fixed) {
> +		p->fixed = 1;
> +	} else
>  		p->fixed = 0;

The original used to check inexpensive one first and then more
expensive one.  The updated one gets it backwards.

Is that intended?

>  	if (p->fixed) {