summaryrefslogtreecommitdiffstats
path: root/command.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-04-30 10:57:37 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-04-30 11:12:01 +0900
commit84c4d3c345352650fce4dbc2df27c4977f9d969e (patch)
tree32dd4d3775e2cefd1a42a11dcb781c73ab442c1f /command.py
parenta8864fba9fd21f412cd0e2c6e072deeb204049bb (diff)
downloadgit-repo-84c4d3c345352650fce4dbc2df27c4977f9d969e.tar.gz
Optimise regex pattern compilation in FindProjects
Make a list of compiled patterns once, and then iterate over that per project, instead of compiling the patterns again on every project. Change-Id: I91ec430d3060ec76d5e6b61facf6b13e343c90a7
Diffstat (limited to 'command.py')
-rw-r--r--command.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/command.py b/command.py
index 66a9e74d..287f4d30 100644
--- a/command.py
+++ b/command.py
@@ -188,9 +188,9 @@ class Command(object):
188 188
189 def FindProjects(self, args): 189 def FindProjects(self, args):
190 result = [] 190 result = []
191 patterns = [re.compile(r'%s' % a, re.IGNORECASE) for a in args]
191 for project in self.GetProjects(''): 192 for project in self.GetProjects(''):
192 for arg in args: 193 for pattern in patterns:
193 pattern = re.compile(r'%s' % arg, re.IGNORECASE)
194 if pattern.search(project.name) or pattern.search(project.relpath): 194 if pattern.search(project.name) or pattern.search(project.relpath):
195 result.append(project) 195 result.append(project)
196 break 196 break