mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-02 16:18:19 +00:00
Optimize [elem] -> (list)elem on output. Saves us headaches.
This commit is contained in:
parent
2948399bf8
commit
f6b472133a
1 changed files with 4 additions and 1 deletions
|
@ -229,9 +229,11 @@ class outscript(object):
|
|||
return self.FindName(expr)
|
||||
|
||||
if nt == 'CONST':
|
||||
if self.foldconst and expr['t'] == 'list' and len(expr['value'])==1 and not self.globalmode:
|
||||
return '(list)' + self.Value2LSL(expr['value'][0])
|
||||
return self.Value2LSL(expr['value'])
|
||||
|
||||
if nt == 'CAST':
|
||||
if nt == 'CAST' or self.foldconst and nt in ('LIST', 'CONST') and len(child)==1 and not self.globalmode:
|
||||
ret = '(' + expr['t'] + ')'
|
||||
expr = child[0]
|
||||
if expr['nt'] in ('CONST', 'IDENT', 'V++', 'V--', 'VECTOR',
|
||||
|
@ -399,6 +401,7 @@ class outscript(object):
|
|||
# Optimize signs
|
||||
self.optsigns = 'optsigns' in options
|
||||
self.optfloats = 'optfloats' in options
|
||||
self.foldconst = 'constfold' in options
|
||||
|
||||
ret = ''
|
||||
self.indent = ' '
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue