diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-05-17 15:25:18 +0100 |
---|---|---|
committer | Benjamin Schubert <contact@benschubert.me> | 2019-05-29 19:47:57 +0100 |
commit | f5ee7679b0b9b469dacc25f71dc46fa788367a1b (patch) | |
tree | 34fb495d6821e969c01dfbf0dc1bf24a6f94731c | |
parent | a521c0f0f65afdd3b4e76b403cd28fe627a94914 (diff) | |
download | buildstream-f5ee7679b0b9b469dacc25f71dc46fa788367a1b.tar.gz |
_variables: Cythonize Variables.subst
-rw-r--r-- | src/buildstream/_variables.pyx | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/buildstream/_variables.pyx b/src/buildstream/_variables.pyx index d12938dd9..d99aaeb78 100644 --- a/src/buildstream/_variables.pyx +++ b/src/buildstream/_variables.pyx @@ -87,7 +87,7 @@ cdef class Variables: # Raises: # LoadError, if the string contains unresolved variable references. # - def subst(self, string): + def subst(self, str string): expstr = _parse_expstr(string) try: @@ -115,7 +115,8 @@ cdef class Variables: # # Here we resolve all of our inputs into a dictionary, ready for use # in subst() - def _resolve(self, node): + # FIXME: node should be a yaml Node if moved + cdef dict _resolve(self, object node): # Special case, if notparallel is specified in the variables for this # element, then override max-jobs to be 1. # Initialize it as a string as all variables are processed as strings. @@ -123,9 +124,12 @@ cdef class Variables: if _yaml.node_get(node, bool, 'notparallel', default_value=False): _yaml.node_set(node, 'max-jobs', str(1)) - ret = {} - for key, value in _yaml.node_items(node): - value = _yaml.node_get(node, str, key) + cdef dict ret = {} + cdef str key + cdef str value + + for key in _yaml.node_keys(node): + value = <str> _yaml.node_get(node, str, key) ret[sys.intern(key)] = _parse_expstr(value) return ret |