LP specification name caching.
This updates our LP calls to obtain blueprint information so that they run faster. Previously calling spec.name would cause an LP hit for each spec. Given that we call lp.specification many times during a reviewday run this was causing slow runtimes. What we do now is just scrap the blueprint name off of the Spec URL (thus avoiding many of the extra LP hits). Change-Id: I4f2cbcc262973b02e3a13b9bba1edde53d5e6d9e
This commit is contained in:
parent
e95925a075
commit
82c28bd48b
@ -18,11 +18,16 @@ class LaunchPad(object):
|
||||
def specifications(self, project):
|
||||
if project not in self.spec_cache:
|
||||
specs = self.project(project).valid_specifications
|
||||
self.spec_cache[project] = specs
|
||||
cache = {}
|
||||
for spec in specs:
|
||||
spec_str = str(spec)
|
||||
spec_name = spec_str[spec_str.index('+spec/') + 6:]
|
||||
cache[spec_name] = spec
|
||||
self.spec_cache[project] = cache
|
||||
return self.spec_cache[project]
|
||||
|
||||
def specification(self, project, spec_name):
|
||||
specs = self.specifications(project)
|
||||
for spec in specs:
|
||||
if spec.name == spec_name:
|
||||
for name, spec in specs.iteritems():
|
||||
if name == spec_name:
|
||||
return spec
|
||||
|
Loading…
x
Reference in New Issue
Block a user