Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 18776:87441497ecaa
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 :-(
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Mon, 11 Mar 2013 12:07:33 -0700 |
parents | c0087d48ec3a |
children | 8048c519dc6a |
comparison
equal
deleted
inserted
replaced
18775:5b05ceb24a8d | 18776:87441497ecaa |
---|---|
2958 """ | 2958 """ |
2959 reflags = re.M | 2959 reflags = re.M |
2960 if opts.get('ignore_case'): | 2960 if opts.get('ignore_case'): |
2961 reflags |= re.I | 2961 reflags |= re.I |
2962 try: | 2962 try: |
2963 regexp = re.compile(pattern, reflags) | 2963 regexp = util.compilere(pattern, reflags) |
2964 except re.error, inst: | 2964 except re.error, inst: |
2965 ui.warn(_("grep: invalid match pattern: %s\n") % inst) | 2965 ui.warn(_("grep: invalid match pattern: %s\n") % inst) |
2966 return 1 | 2966 return 1 |
2967 sep, eol = ':', '\n' | 2967 sep, eol = ':', '\n' |
2968 if opts.get('print0'): | 2968 if opts.get('print0'): |