Re: [PATCH 2/2] grep: don't call regexec() for fixed strings
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 10, 2009, 20:37 UTC
- Message-ID
- <7vbpuex5hm.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <4967DB4A.2000702@lsrfire.ath.cx>
René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
Show 6 quoted lines
> Add the new flag "fixed" to struct grep_pat and set it if the pattern > is doesn't contain any regex control characters in addition to if the > flag -F/--fixed-strings was specified. > > This gives a nice speed up on msysgit, where regexec() seems to be > extra slow. Before (best of five runs):
Thanks, and...
Show 9 quoted lines
> static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
> {
> - int err = regcomp(&p->regexp, p->pattern, opt->regflags);
> + int err;
> +
> + if (opt->fixed || is_fixed(p->pattern))
> + p->fixed = 1;
> + if (opt->regflags & REG_ICASE)
> + p->fixed = 0;... thanks again for being extra careful. That's why I *love* your patches.