You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:48:05 UTC

[buildstream] 12/16: _variables.pyx: Improve _fast_expand_var()

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

not-in-ldap pushed a commit to branch tristan/variables-refactor
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 23510dab2732e5cd10868335bed61ef25fab079a
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Sat Jul 18 15:37:57 2020 +0900

    _variables.pyx: Improve _fast_expand_var()
    
      * Reduce typechecking using some typecasts
    
      * Reduce dictionary lookups by using a temporary variable
---
 src/buildstream/_variables.pyx | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/buildstream/_variables.pyx b/src/buildstream/_variables.pyx
index b5d62c1..d6384f9 100644
--- a/src/buildstream/_variables.pyx
+++ b/src/buildstream/_variables.pyx
@@ -374,12 +374,15 @@ cdef class Variables:
     #################################################################
     cdef str _fast_expand_var(self, str name, int counter = 0):
         cdef str sub
+        cdef list value_expression
 
-        if len(self._values[name]) > 1:
-            sub = self._fast_expand_value_expression(<list> self._values[name], counter)
-            self._values[name] = [sys.intern(sub)]
+        value_expression = <list> self._values[name]
+        if len(value_expression) > 1:
+            sub = self._fast_expand_value_expression(value_expression, counter)
+            value_expression = [sys.intern(sub)]
+            self._values[name] = value_expression
 
-        return self._values[name][0]
+        return <str> value_expression[0]
 
     cdef str _fast_expand_value_expression(self, list value, int counter = 0):
         if counter > 1000: