Skip to content
Snippets Groups Projects
Commit a149a0d0 authored by Daniel Silverstone's avatar Daniel Silverstone
Browse files

_context.py: Cache result of get_strict()


While get_strict() doesn't look expensive per-se, it is called so many
times that it is valuable to cache the result once computed.  Since I
don't think it can change once it is computable, cache it immediately
that becomes possible and we save 20s in my test case.

Signed-off-by: default avatarDaniel Silverstone <daniel.silverstone@codethink.co.uk>
parent 7c86ea0d
No related branches found
No related tags found
No related merge requests found
Pipeline #47191796 passed
......@@ -361,14 +361,17 @@ class Context():
# (bool): Whether or not to use strict build plan
#
def get_strict(self):
if self._strict_build_plan is None:
# Either we're not overridden or we've never worked it out before
# so work out if we should be strict, and then cache the result
toplevel = self.get_toplevel_project()
overrides = self.get_overrides(toplevel.name)
self._strict_build_plan = _yaml.node_get(overrides, bool, 'strict', default_value=True)
# If it was set by the CLI, it overrides any config
if self._strict_build_plan is not None:
return self._strict_build_plan
toplevel = self.get_toplevel_project()
overrides = self.get_overrides(toplevel.name)
return _yaml.node_get(overrides, bool, 'strict', default_value=True)
# Ditto if we've already computed this, then we return the computed
# value which we cache here too.
return self._strict_build_plan
# get_cache_key():
#
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment