# HG changeset patch # User Gregory Szorc # Date 1348280926 25200 # Node ID 6e05aa1b536da05fd0f945e98b8f1d47c5c2cd53 # Parent 3b82cf6ac73ad8455a632516735070610eb5cd32 Optimize get_git_author Pre-compile regular expression. Prevent extra key lookup in author_map. diff --git a/hggit/git_handler.py b/hggit/git_handler.py --- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -29,6 +29,8 @@ import util from overlay import overlayrepo +RE_GIT_AUTHOR = re.compile('^(.*?) ?\<(.*?)(?:\>(.*))?$') + class GitProgress(object): """convert git server progress strings into mercurial progress""" def __init__(self, ui): @@ -433,12 +435,10 @@ author = ctx.user() # see if a translation exists - if author in self.author_map: - author = self.author_map[author] + author = self.author_map.get(author, author) # check for git author pattern compliance - regex = re.compile('^(.*?) ?\<(.*?)(?:\>(.*))?$') - a = regex.match(author) + a = RE_GIT_AUTHOR.match(author) if a: name = self.get_valid_git_username_email(a.group(1))