diff options
Diffstat (limited to 'src/buildstream/_loader/loadelement.py')
-rw-r--r-- | src/buildstream/_loader/loadelement.py | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/buildstream/_loader/loadelement.py b/src/buildstream/_loader/loadelement.py index 24b4e7293..9296acc50 100644 --- a/src/buildstream/_loader/loadelement.py +++ b/src/buildstream/_loader/loadelement.py @@ -20,7 +20,7 @@ # System imports from itertools import count -from pyroaring import BitMap, FrozenBitMap # pylint: disable=no-name-in-module +from pyroaring import BitMap # pylint: disable=no-name-in-module # BuildStream toplevel imports from .. import _yaml @@ -111,33 +111,27 @@ class LoadElement(): # (bool): True if this LoadElement depends on 'other' # def depends(self, other): - self._ensure_depends_cache() return other.node_id in self._dep_cache - ########################################### - # Private Methods # - ########################################### - def _ensure_depends_cache(self): - - if self._dep_cache: - return + # prepare_depends_cache() + # + # Prepares the dependency cache used by depends() + # + # This should be called once all dependencies have been added + # to this LoadElement instance. + def prepare_depends_cache(self): self._dep_cache = BitMap() for dep in self.dependencies: elt = dep.element - # Ensure the cache of the element we depend on - elt._ensure_depends_cache() - # We depend on this element self._dep_cache.add(elt.node_id) # And we depend on everything this element depends on self._dep_cache.update(elt._dep_cache) - self._dep_cache = FrozenBitMap(self._dep_cache) - # _extract_depends_from_node(): # |