diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-04-30 10:57:37 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-04-30 11:12:01 +0900 |
commit | 84c4d3c345352650fce4dbc2df27c4977f9d969e (patch) | |
tree | 32dd4d3775e2cefd1a42a11dcb781c73ab442c1f /command.py | |
parent | a8864fba9fd21f412cd0e2c6e072deeb204049bb (diff) | |
download | git-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.py | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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 |