From 3686d490a2a161f5b69c8c11ba06938faa3f4073 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sat, 28 Jan 2017 03:36:25 +0100 Subject: [PATCH] Improve savings in ShrinkNames. The reusable names table was being emptied as identifiers were used. This was sub-optimal for function parameters, because new identifiers would need to be created when exhausted. Reset the reusable names list to a saved copy every time a new parameter list is started, in a similar fashion to what we did with the sequentially generated identifiers. --- lslopt/lslrenamer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lslopt/lslrenamer.py b/lslopt/lslrenamer.py index 4757c41..f7e749d 100644 --- a/lslopt/lslrenamer.py +++ b/lslopt/lslrenamer.py @@ -156,6 +156,8 @@ class renamer(object): # long distinct names. First = True restart = self.WordFirstChar + restartReusable = ReusableNames + ReusableNames = restartReusable.copy() for table in self.symtab: if First: First = False @@ -174,9 +176,8 @@ class renamer(object): # Parameter tables are isolated from each other. InParams = True self.WordFirstChar = restart + ReusableNames = restartReusable.copy() # Same procedure as for global vars - # Not the best strategy (using locally unique names would - # do a better job) but hey. if ReusableNames: short = ReusableNames.pop() self.UsedNames.add(short)