From 1f3d3626d0fb716f1566b0cafab738a8008d3881 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 27 Mar 2012 18:49:59 -0700 Subject: [PATCH] varexpand: don't cache results Caching wasn't really necessary here, and it didn't properly account for input differences in the 'mydict' parameter. --- pym/portage/util/__init__.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py index dd692a13a..fc4b75b20 100644 --- a/pym/portage/util/__init__.py +++ b/pym/portage/util/__init__.py @@ -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 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 -- 2.26.2