You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:54:59 UTC

[buildstream] 15/27: _variables.pyx: Use ObjectArray to accumulate deps in _resolve()

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/partial-variables-manual-string-join
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit d5aab43b018ea05214db744d659650ae13d6c55a
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Fri Jul 3 02:11:56 2020 +0900

    _variables.pyx: Use ObjectArray to accumulate deps in _resolve()
---
 src/buildstream/_variables.pyx | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/buildstream/_variables.pyx b/src/buildstream/_variables.pyx
index d6c7445..c1c368a 100644
--- a/src/buildstream/_variables.pyx
+++ b/src/buildstream/_variables.pyx
@@ -274,10 +274,12 @@ cdef class Variables:
         cdef Py_ssize_t idx = 0
 
         cdef str resolved_value = None
-
-        cdef list deps = []
         cdef bint first_iteration = True
 
+        # We'll be collecting the values to resolve at the end in here
+        cdef ObjectArray values
+        object_array_init(&(values), -1)
+
         # While iterating over the first loop, we collect all of the variable
         # dependencies, and perform all required validation.
         #
@@ -314,7 +316,8 @@ cdef class Variables:
 
                 # Queue up this value to be resolved in the next loop
                 if iter_value._resolved is None:
-                    deps.append(iter_value)
+
+                    object_array_append(&(values), <PyObject *>iter_value)
 
                     # Queue up it's dependencies for resolution
                     iter_value_deps = iter_value.dependencies()
@@ -331,13 +334,16 @@ cdef class Variables:
         # backwards and the last (leftmost) resolved value is the one
         # we want to return.
         #
-        while deps:
-            iter_value = deps.pop()
+        idx = values.length -1
+        while idx >= 0:
+            iter_value = <Value>values.array[idx]
             resolved_value = iter_value.resolve(self._values)
+            idx -= 1
 
         # Cleanup
         #
         object_array_free(&(initial_deps))
+        object_array_free(&(values))
 
         return resolved_value