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.
This commit is contained in:
Sei Lisa 2017-01-28 03:36:25 +01:00
parent 8358fd5012
commit 3686d490a2

View file

@ -156,6 +156,8 @@ class renamer(object):
# long distinct names. # long distinct names.
First = True First = True
restart = self.WordFirstChar restart = self.WordFirstChar
restartReusable = ReusableNames
ReusableNames = restartReusable.copy()
for table in self.symtab: for table in self.symtab:
if First: if First:
First = False First = False
@ -174,9 +176,8 @@ class renamer(object):
# Parameter tables are isolated from each other. # Parameter tables are isolated from each other.
InParams = True InParams = True
self.WordFirstChar = restart self.WordFirstChar = restart
ReusableNames = restartReusable.copy()
# Same procedure as for global vars # Same procedure as for global vars
# Not the best strategy (using locally unique names would
# do a better job) but hey.
if ReusableNames: if ReusableNames:
short = ReusableNames.pop() short = ReusableNames.pop()
self.UsedNames.add(short) self.UsedNames.add(short)