varexpand: don't cache results
authorZac Medico <zmedico@gentoo.org>
Wed, 28 Mar 2012 01:49:59 +0000 (18:49 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 28 Mar 2012 01:49:59 +0000 (18:49 -0700)
Caching wasn't really necessary here, and it didn't properly account
for input differences in the 'mydict' parameter.

pym/portage/util/__init__.py

index dd692a13a36bc00b96ecd6e89c37116c0dc2c8ee..fc4b75b20ddb3be7fa1fe885bd468099a05d0d6e 100644 (file)
@@ -645,15 +645,10 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
        except Exception as e:
                raise portage.exception.ParseError(str(e)+" in "+mycfg)
        return mykeys
-       
-#cache expansions of constant strings
-cexpand={}
+
 def varexpand(mystring, mydict=None):
        if mydict is None:
                mydict = {}
-       newstring = cexpand.get(" "+mystring, None)
-       if newstring is not None:
-               return newstring
 
        """
        new variable expansion code.  Preserves quotes, handles \n, etc.
@@ -666,7 +661,7 @@ def varexpand(mystring, mydict=None):
        insing=0
        indoub=0
        pos=1
-       newstring=" "
+       newstring = ""
        while (pos<len(mystring)):
                if (mystring[pos]=="'") and (mystring[pos-1]!="\\"):
                        if (indoub):
@@ -724,7 +719,6 @@ def varexpand(mystring, mydict=None):
                                while mystring[pos] in validchars:
                                        if (pos+1)>=len(mystring):
                                                if braced:
-                                                       cexpand[mystring]=""
                                                        return ""
                                                else:
                                                        pos=pos+1
@@ -733,12 +727,10 @@ def varexpand(mystring, mydict=None):
                                myvarname=mystring[myvstart:pos]
                                if braced:
                                        if mystring[pos]!="}":
-                                               cexpand[mystring]=""
                                                return ""
                                        else:
                                                pos=pos+1
                                if len(myvarname)==0:
-                                       cexpand[mystring]=""
                                        return ""
                                numvars=numvars+1
                                if myvarname in mydict:
@@ -749,9 +741,8 @@ def varexpand(mystring, mydict=None):
                else:
                        newstring=newstring+mystring[pos]
                        pos=pos+1
-       if numvars==0:
-               cexpand[mystring]=newstring[1:]
-       return newstring[1:]    
+
+       return newstring
 
 # broken and removed, but can still be imported
 pickle_write = None