This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch bschubert/optimize-element-init in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit ce10465da264f69a2d68c8d6b580b85aef2edb5b Author: Benjamin Schubert <[email protected]> AuthorDate: Thu Oct 10 15:21:03 2019 +0100 _element.pyx: Optimize expand_splits We don't need to create a new list when doing the expand split, we can just reuse the current SequenceNode. This gives another speedup to this method. --- src/buildstream/_element.pyx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/buildstream/_element.pyx b/src/buildstream/_element.pyx index f4e2011..388f295 100644 --- a/src/buildstream/_element.pyx +++ b/src/buildstream/_element.pyx @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see <http://www.gnu.org/licenses/>. # -from .node cimport MappingNode, SequenceNode +from .node cimport MappingNode, ScalarNode, SequenceNode from ._variables cimport Variables @@ -22,16 +22,18 @@ from ._variables cimport Variables def expand_splits(MappingNode element_public not None, Variables variables not None): cdef MappingNode element_bst = element_public.get_mapping('bst', default={}) cdef MappingNode element_splits = element_bst.get_mapping('split-rules', default={}) + cdef str domain cdef list new_splits cdef SequenceNode splits + cdef ScalarNode split - # Resolve any variables in the public split rules directly - for domain, splits in element_splits.items(): - new_splits = [ - variables.subst(split.strip()) - for split in splits.as_str_list() - ] - element_splits[domain] = new_splits + if element_splits: + # Resolve any variables in the public split rules directly + for domain, splits in element_splits.items(): + for split in splits: + split.value = variables.subst(split.as_str()) + else: + element_public['split-rules'] = {} return element_public
