Add !llStringLength(s) -> s == "" optimization.

This commit is contained in:
Sei Lisa 2017-08-14 21:41:08 +02:00
parent 0d76e09567
commit 6693022dfb

View file

@ -371,6 +371,17 @@ class foldconst(object):
# !! does *not* cancel out (unless in cond)
subexpr = child[0]
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:
node['SEF'] = True
if subexpr['nt'] == 'CONST':