@@ -20,6 +20,9 @@ class Commit(LazyMixin):
2020 This class will act lazily on some of its attributes and will query the
2121 value on demand only if it involves calling the git binary.
2222 """
23+ # precompiled regex
24+ re_actor_epoch = re .compile (r'^.+? (.*) (\d+) .*$' )
25+
2326 def __init__ (self , repo , id , tree = None , author = None , authored_date = None ,
2427 committer = None , committed_date = None , message = None , parents = None ):
2528 """
@@ -246,12 +249,6 @@ def diffs(self):
246249 """
247250 if not self .parents :
248251 d = self .repo .git .show (self .id , '-M' , full_index = True , pretty = 'raw' )
249- if re .search (r'diff --git a' , d ):
250- if not re .search (r'^diff --git a' , d ):
251- p = re .compile (r'.+?(diff --git a)' , re .MULTILINE | re .DOTALL )
252- d = p .sub (r'diff --git a' , d , 1 )
253- else :
254- d = ''
255252 return diff .Diff .list_from_string (self .repo , d )
256253 else :
257254 return self .diff (self .repo , self .parents [0 ].id , self .id )
@@ -291,6 +288,6 @@ def _actor(cls, line):
291288 Returns
292289 [Actor, gmtime(acted at time)]
293290 """
294- m = re . search (r'^.+? (.*) (\d+) .*$' , line )
291+ m = cls . re_actor_epoch . search (line )
295292 actor , epoch = m .groups ()
296293 return (Actor .from_string (actor ), time .gmtime (int (epoch )))
0 commit comments