summaryrefslogtreecommitdiff
path: root/src/buildstream/_loader
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-06-05 21:16:50 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-06-06 15:53:43 +0000
commit8f6e36acea77b35f454a53383a94b8fb838957fd (patch)
tree65a424a26f1e02d2776b2ff3e983cddc4ab34690 /src/buildstream/_loader
parentbaec142e623f9e8a4efd93183ac2f7ef15d84b06 (diff)
downloadbuildstream-8f6e36acea77b35f454a53383a94b8fb838957fd.tar.gz
_loader/types: cimport yaml functions for better speed
- _yaml: export node_validate function as Cython, as it was not done before. This requires rewriting the function to remove a closure. - Optimize node check by not calling is_node().
Diffstat (limited to 'src/buildstream/_loader')
-rw-r--r--src/buildstream/_loader/types.pyx16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/buildstream/_loader/types.pyx b/src/buildstream/_loader/types.pyx
index a9aa3ab32..5e4e12666 100644
--- a/src/buildstream/_loader/types.pyx
+++ b/src/buildstream/_loader/types.pyx
@@ -18,7 +18,7 @@
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
from .._exceptions import LoadError, LoadErrorReason
-from .. import _yaml
+from .. cimport _yaml
# Symbol():
@@ -51,14 +51,14 @@ class Symbol():
# A simple object describing a dependency
#
# Args:
-# name (str): The element name
+# name (str or Node): The element name
# dep_type (str): The type of dependency, can be
# Symbol.ALL, Symbol.BUILD, or Symbol.RUNTIME
# junction (str): The element name of the junction, or None
-# provenance (Provenance): The YAML node provenance of where this
-# dependency was declared
+# provenance (ProvenanceInformation): The YAML node provenance of where this
+# dependency was declared
#
-class Dependency():
+class Dependency:
def __init__(self, dep, provenance, default_dep_type=None):
self.provenance = provenance
@@ -67,7 +67,7 @@ class Dependency():
self.dep_type = default_dep_type
self.junction = None
- elif _yaml.is_node(dep):
+ elif type(dep) is _yaml.Node and type(dep.value) is dict:
if default_dep_type:
_yaml.node_validate(dep, ['filename', 'junction'])
dep_type = default_dep_type
@@ -75,7 +75,7 @@ class Dependency():
_yaml.node_validate(dep, ['filename', 'type', 'junction'])
# Make type optional, for this we set it to None
- dep_type = _yaml.node_get(dep, str, Symbol.TYPE, default_value=None)
+ dep_type = _yaml.node_get(dep, str, Symbol.TYPE, None, None)
if dep_type is None or dep_type == Symbol.ALL:
dep_type = None
elif dep_type not in [Symbol.BUILD, Symbol.RUNTIME]:
@@ -86,7 +86,7 @@ class Dependency():
self.name = _yaml.node_get(dep, str, Symbol.FILENAME)
self.dep_type = dep_type
- self.junction = _yaml.node_get(dep, str, Symbol.JUNCTION, default_value=None)
+ self.junction = _yaml.node_get(dep, str, Symbol.JUNCTION, None, None)
else:
raise LoadError(LoadErrorReason.INVALID_DATA,