mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Add !llStringLength(s) -> s == "" optimization.
This commit is contained in:
parent
0d76e09567
commit
6693022dfb
1 changed files with 11 additions and 0 deletions
|
@ -371,6 +371,17 @@ class foldconst(object):
|
||||||
# !! does *not* cancel out (unless in cond)
|
# !! does *not* cancel out (unless in cond)
|
||||||
subexpr = child[0]
|
subexpr = child[0]
|
||||||
snt = subexpr['nt']
|
snt = subexpr['nt']
|
||||||
|
|
||||||
|
if snt == 'FNCALL' and subexpr['name'] == 'llStringLength':
|
||||||
|
# !llStringLength(expr) -> expr == ""
|
||||||
|
parent[index] = {'nt':'==', 't':'integer',
|
||||||
|
'ch':[subexpr['ch'][0],
|
||||||
|
{'nt':'CONST', 't':'string',
|
||||||
|
'value':u""}]}
|
||||||
|
# new node is SEF if the argument to llStringLength is
|
||||||
|
if 'SEF' in subexpr['ch'][0]:
|
||||||
|
parent[index]['SEF'] = True
|
||||||
|
return
|
||||||
if 'SEF' in subexpr:
|
if 'SEF' in subexpr:
|
||||||
node['SEF'] = True
|
node['SEF'] = True
|
||||||
if subexpr['nt'] == 'CONST':
|
if subexpr['nt'] == 'CONST':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue