[PATCH] grep: use re2 if possible
Augie Fackler
raf at durin42.com
Mon Mar 11 19:26:05 CDT 2013
LGTM
On Mar 11, 2013, at 2:11 PM, Bryan O'Sullivan <bos at serpentine.com> wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano at fb.com>
> # Date 1363028853 25200
> # Node ID 15e77967d1b3bb5eb9dfb6e7bfe94691d280af74
> # Parent c6945de2450811e4d7240f1e083eaea26d81bd2b
> grep: use re2 if possible
>
> Since re2 is enormously faster than Python's re module, this should
> help performance, ceteris paribus. grep currently has other huge
> performance problems that mask any gain :-(
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -2960,7 +2960,7 @@ def grep(ui, repo, pattern, *pats, **opt
> if opts.get('ignore_case'):
> reflags |= re.I
> try:
> - regexp = re.compile(pattern, reflags)
> + regexp = util.compilere(pattern, reflags)
> except re.error, inst:
> ui.warn(_("grep: invalid match pattern: %s\n") % inst)
> return 1
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list