mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Generate labels sequentially rather than randomly.
This commit is contained in:
parent
79dff25769
commit
8488254d53
1 changed files with 7 additions and 9 deletions
|
@ -24,8 +24,6 @@ from lslcommon import Key, Vector, Quaternion
|
|||
import lslcommon
|
||||
import lslfuncs
|
||||
import sys, re
|
||||
from base64 import b64encode
|
||||
import random
|
||||
|
||||
# Note this module was basically written from bottom to top, which may help
|
||||
# reading it.
|
||||
|
@ -208,13 +206,9 @@ class parser(object):
|
|||
# Utility function
|
||||
def GenerateLabel(self):
|
||||
while True:
|
||||
x = random.randint(0, 16777215)
|
||||
unique = 'J_' + b64encode(chr(x>>16) + chr((x>>8)&255)
|
||||
+ chr(x&255)).replace('+', '_')
|
||||
x = random.randint(0, 16777215)
|
||||
unique += b64encode(chr(x>>16) + chr((x>>8)&255)
|
||||
+ chr(x&255)).replace('+', '_')
|
||||
if '/' not in unique not in self.locallabels:
|
||||
self.labelcnt += 1
|
||||
unique = 'J_autoGen%05d' % self.labelcnt
|
||||
if unique not in self.locallabels:
|
||||
break
|
||||
self.locallabels.add(unique)
|
||||
return unique
|
||||
|
@ -2376,6 +2370,10 @@ list lazy_list_set(list L, integer i, list v)
|
|||
self.script = script
|
||||
self.length = len(script)
|
||||
|
||||
self.labelcnt = 0
|
||||
|
||||
# Options
|
||||
|
||||
# Extended expressions in globals (needs support from the optimizer to work)
|
||||
self.extendedglobalexpr = 'extendedglobalexpr' in options
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue