diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-09 12:14:02 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-09 15:13:05 +0200 |
commit | 52ab307935bd2bbda52f853f9fc6b49f01897727 (patch) | |
tree | 8950b9658b4f0fba902e80077ba5ee88f50c4541 /lib/git/actor.py | |
parent | 07c20b4231b12fee42d15f1c44c948ce474f5851 (diff) | |
download | gitpython-52ab307935bd2bbda52f853f9fc6b49f01897727.tar.gz |
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 )
Diffstat (limited to 'lib/git/actor.py')
-rw-r--r-- | lib/git/actor.py | 8 |
1 files changed, 6 insertions, 2 deletions
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: |