[StGIT PATCH 4/4] Compile regexp just once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It's a waste of time to recompile the same regexp every time we go
through the loop.

Signed-off-by: Karl Hasselström <kha@xxxxxxxxxxx>

---

 stgit/git.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

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
 

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux