From 216a1524c4acbd9952ffaeec054e30cf14dde5fc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Karl=20Hasselstr=C3=B6m?= Date: Sat, 25 Aug 2007 20:10:38 +0200 Subject: [PATCH] Compile regexp just once MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It's a waste of time to recompile the same regexp every time we go through the loop. Signed-off-by: Karl Hasselström --- stgit/git.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stgit/git.py b/stgit/git.py index 1807f69..14b4c81 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -275,8 +275,9 @@ def local_changes(verbose = True): def get_heads(): heads = [] + hr = re.compile(r'^[0-9a-f]{40} refs/heads/(.+)$') for line in _output_lines(['git-show-ref', '--heads']): - m = re.match('^[0-9a-f]{40} refs/heads/(.+)$', line) + m = hr.match(line) heads.append(m.group(1)) return heads -- 2.11.0