spec performance: don't parse in from_node_dict

Constructing a spec from a name instead of setting name directly forces
from_node_dict to call Spec.parse(), which is slow. Avoid this by using a
zero-arg constructor and setting name directly.
This commit is contained in:
Todd Gamblin 2021-02-05 23:27:05 -08:00 committed by Massimiliano Culpo
parent 2fbc8caf86
commit 6fe931ccb1

View file

@ -1786,10 +1786,12 @@ def from_node_dict(node):
name = next(iter(node))
node = node[name]
spec = Spec(name, full_hash=node.get('full_hash', None))
spec = Spec()
spec.name = name
spec.namespace = node.get('namespace', None)
spec._hash = node.get('hash', None)
spec._build_hash = node.get('build_hash', None)
spec._full_hash = node.get('full_hash', None)
if 'version' in node or 'versions' in node:
spec.versions = vn.VersionList.from_dict(node)