Re: [PATCH v4 05/19] grep: remove redundant `regflags &= ~REG_EXTENDED` assignments
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 26, 2017, 04:50 UTC
- Message-ID
- <xmqq4lxbsrfj.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20170425210548.24612-6-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 7 quoted lines
> Remove redundant assignments to the "regflags" variable. There are no
> code paths that have previously set the regflags to anything, and
> certainly not to `|= REG_EXTENDED`.
>
> This code gave the impression that it had to reset its environment,
> but it doesn't. This dates back to the initial introduction of
> git-grep in commit 5010cb5fcc ("built-in "git grep"", 2006-04-30).As long as nobody calls grep_commit_pattern_type() more than once while interpreting something like "grep -E -G -P -F -G" (i.e. "I cannot quite decide which pattern type I want to give..."), this change should be safe.
This made me wonder if we should be doing "opt->regflags = REG_EXTENDED" for ERE from the same "this is only called once" reasoning, but regflags is a collection of bits, and presumably bits other than REG_EXTENDED can be set before the control reaches grep_commit_pattern_type(), so that one must stay as-is, i.e. "opt->regflags |= REG_EXTENDED".
Thanks.