database: do not redundantly mark specs concrete

Speed up reads by not traversing each spec recursively when marking them
concrete.
This commit is contained in:
Todd Gamblin 2021-02-05 23:34:18 -08:00 committed by Massimiliano Culpo
parent 6fe931ccb1
commit 52508e6ee7
2 changed files with 9 additions and 5 deletions

View File

@ -795,7 +795,7 @@ def invalid_record(hash_key, error):
# do it *while* we're constructing specs,it causes hashes to be # do it *while* we're constructing specs,it causes hashes to be
# cached prematurely. # cached prematurely.
for hash_key, rec in data.items(): for hash_key, rec in data.items():
rec.spec._mark_concrete() rec.spec._mark_root_concrete()
self._data = data self._data = data

View File

@ -2538,6 +2538,13 @@ def concretize(self, tests=False):
else: else:
self._old_concretize(tests) self._old_concretize(tests)
def _mark_root_concrete(self, value=True):
"""Mark just this spec (not dependencies) concrete."""
if (not value) and self.concrete and self.package.installed:
return
self._normal = value
self._concrete = value
def _mark_concrete(self, value=True): def _mark_concrete(self, value=True):
"""Mark this spec and its dependencies as concrete. """Mark this spec and its dependencies as concrete.
@ -2545,10 +2552,7 @@ def _mark_concrete(self, value=True):
unless there is a need to force a spec to be concrete. unless there is a need to force a spec to be concrete.
""" """
for s in self.traverse(): for s in self.traverse():
if (not value) and s.concrete and s.package.installed: s._mark_root_concrete(value)
continue
s._normal = value
s._concrete = value
def concretized(self, tests=False): def concretized(self, tests=False):
"""This is a non-destructive version of concretize(). """This is a non-destructive version of concretize().