summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-06-27 17:06:36 +0200
committerValentin David <valentin.david@codethink.co.uk>2018-07-02 16:24:53 +0200
commitc31e5a10796a26aabe83b819b255688e56682c0a (patch)
tree660ad06ff5ffb086e5fa1489e40d5b9cf21899f2
parentd97b2c1ee7ef4eab2fb1f11079fb22e779693f08 (diff)
downloadbuildstream-c31e5a10796a26aabe83b819b255688e56682c0a.tar.gz
buildstream/_includes.py: Cache loaded fragments.
-rw-r--r--buildstream/_includes.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/buildstream/_includes.py b/buildstream/_includes.py
index 718cd8283..eed73a0a5 100644
--- a/buildstream/_includes.py
+++ b/buildstream/_includes.py
@@ -8,6 +8,7 @@ class Includes:
def __init__(self, loader, valid_keys=None):
self._loader = loader
self._valid_keys = valid_keys
+ self._loaded = {}
def process(self, node):
while True:
@@ -35,7 +36,10 @@ class Includes:
directory = junction_loader.project.directory
else:
directory = self._loader.project.directory
- return _yaml.load(os.path.join(directory, include))
+ file_path = os.path.join(directory, include)
+ if file_path not in self._loaded:
+ self._loaded[file_path] = _yaml.load(os.path.join(directory, include))
+ return self._loaded[file_path]
def _process_value(self, value):
if isinstance(value, Mapping):