From: Junio C Hamano Date: Sat, 10 Jan 2009 20:37:09 GMT Subject: Re: [PATCH 2/2] grep: don't call regexec() for fixed strings Message-ID: <7vbpuex5hm.fsf@gitster.siamese.dyndns.org> In-Reply-To: <4967DB4A.2000702@lsrfire.ath.cx> René Scharfe writes: > 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... > 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.