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:54 UTC

[buildstream] 10/27: _variables.pyx: Don't hold onto ProvenanceInformation, hold onto nodes instead.

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 0bac4011e1c52ba21e10ecccb7cfb176429ccbe6
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Thu Jul 2 16:57:51 2020 +0900

    _variables.pyx: Don't hold onto ProvenanceInformation, hold onto nodes instead.
    
    Since ProvenanceInformation() is generated on the fly, they add overhead
    to generate them and overhead in memory.
---
 src/buildstream/_variables.pyx | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/buildstream/_variables.pyx b/src/buildstream/_variables.pyx
index 67d41b5..18772ae 100644
--- a/src/buildstream/_variables.pyx
+++ b/src/buildstream/_variables.pyx
@@ -345,7 +345,7 @@ cdef class Variables:
                 referee_value = None
 
             if referee_value:
-                provenance = referee_value.provenance
+                provenance = referee_value.get_provenance()
 
             error_message = "Reference to undefined variable '{}'".format(varname)
             if provenance:
@@ -419,7 +419,7 @@ cdef class ResolutionStep:
                 referee = self.referee
             value = values[referee]
 
-            error_lines.append("{}: Variable '{}' refers to variable '{}'".format(value.provenance, referee, step.referee))
+            error_lines.append("{}: Variable '{}' refers to variable '{}'".format(value.get_provenance(), referee, step.referee))
             step = step.parent
 
         raise LoadError("Circular dependency detected on variable '{}'".format(self.referee),
@@ -434,7 +434,7 @@ cdef EMPTY_SET = set()
 # Represents a variable value
 #
 cdef class Value:
-    cdef ProvenanceInformation provenance
+    cdef ScalarNode _node
     cdef ValueClass _value_class
     cdef str _resolved
 
@@ -446,14 +446,20 @@ cdef class Value:
     #    node (ScalarNode): The node representing this value.
     #
     cdef init(self, ScalarNode node):
-
-        # Public
-        self.provenance = node.get_provenance()
-
-        # Private
+        self._node = node
         self._value_class = self._load_value_class(node.as_str())
         self._resolved = None
 
+    # get_provenance():
+    #
+    # Fetches the provenance of this Value
+    #
+    # Returns:
+    #    (ProvenanceInformation): The provenance of this Value
+    #
+    cdef get_provenance(self):
+        return self._node.get_provenance()
+
     # resolve()
     #
     # Resolve the value of this variable, this function expects