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

[buildstream] 13/27: _variables.pyx: Only intern the value class strings, not the variable names

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

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

commit c43bbf92ddc1c0a17981114557306a8447ffe7d7
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Thu Jul 2 21:58:58 2020 +0900

    _variables.pyx: Only intern the value class strings, not the variable names
    
    It would appear that variable name interning adds more expense than
    what we save on variable lookups.
---
 src/buildstream/_variables.pyx | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/src/buildstream/_variables.pyx b/src/buildstream/_variables.pyx
index 152a8d3..a9a14eb 100644
--- a/src/buildstream/_variables.pyx
+++ b/src/buildstream/_variables.pyx
@@ -181,7 +181,6 @@ cdef class Variables:
         cdef Value value
 
         for key, value_node in node.items():
-            key = <object> sys.intern(<str> key)
             value = Value()
             value.init(<ScalarNode> value_node)
             ret[key] = value
@@ -279,7 +278,6 @@ cdef class Variables:
         # Each iteration processes a ResolutionStep object and has the possibility
         # to enque more ResolutionStep objects as a result.
         #
-        name = sys.intern(name)
         cdef PyObject *names[1]
         names[0] = <PyObject *>name
 
@@ -548,14 +546,15 @@ cdef class Value:
     #
     cdef ValueClass _load_value_class(self, str string):
         cdef ValueClass ret
-        cdef str internal_string = sys.intern(string)
+
+        string = sys.intern(string)
 
         try:
-            ret = VALUE_CLASS_TABLE[internal_string]
+            ret = VALUE_CLASS_TABLE[string]
         except KeyError:
             ret = ValueClass()
-            ret.init(internal_string)
-            VALUE_CLASS_TABLE[internal_string] = ret
+            ret.init(string)
+            VALUE_CLASS_TABLE[string] = ret
 
         return ret
 
@@ -660,12 +659,6 @@ cdef class ValueClass:
             split = <str> split_object
             if split:
 
-                # Use an intern for the part, this will not only
-                # save memory but it will speed up lookups in the
-                # case that the part in question is used to lookup
-                # variable values.
-                split = <str> sys.intern(split)
-
                 if (idx % 2) == 0:
                     is_variable = False
                 else: