From 52ab307935bd2bbda52f853f9fc6b49f01897727 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 9 Oct 2009 12:14:02 +0200 Subject: diff regex are now precompiled on class level, renamed a|b_blob to a|b_blob_id as it better reflects the actual value actor regex now precompiled on class level blob regex now precompiled on class level; made blame method more readable and faster although it can still be improved by making assumptions about the blame format and by reading the git command stream directly ( which is a general issue right now ) --- lib/git/actor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/git/actor.py') diff --git a/lib/git/actor.py b/lib/git/actor.py index bc1a4479..28f50e73 100644 --- a/lib/git/actor.py +++ b/lib/git/actor.py @@ -10,6 +10,10 @@ class Actor(object): """Actors hold information about a person acting on the repository. They can be committers and authors or anything with a name and an email as mentioned in the git log entries.""" + # precompiled regex + name_only_regex = re.compile( r'<.+>' ) + name_email_regex = re.compile( r'(.*) <(.+?)>' ) + def __init__(self, name, email): self.name = name self.email = email @@ -34,8 +38,8 @@ class Actor(object): Returns Actor """ - if re.search(r'<.+>', string): - m = re.search(r'(.*) <(.+?)>', string) + if cls.name_only_regex.search(string): + m = cls.name_email_regex.search(string) name, email = m.groups() return Actor(name, email) else: -- cgit v1.2.1