mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Save a comparison (fixes a FIXME)
This commit is contained in:
parent
0808938894
commit
e88e39127b
1 changed files with 19 additions and 19 deletions
|
@ -1347,27 +1347,27 @@ class foldconst(object):
|
||||||
node.ch = [child[a]]
|
node.ch = [child[a]]
|
||||||
return
|
return
|
||||||
|
|
||||||
#FIXME: Could remove one comparison
|
if nt == '||':
|
||||||
if nt == '&&' or nt == '||':
|
# Expand to its equivalent a || b -> !!(a | b)
|
||||||
if nt == '||':
|
node = nr(nt='|', t='integer', ch=[child[0], child[1]],
|
||||||
# Expand to its equivalent a || b -> !!(a | b)
|
SEF=child[0].SEF and child[1].SEF)
|
||||||
node = nr(nt='|', t='integer', ch=[child[0], child[1]],
|
node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF)
|
||||||
SEF=child[0].SEF and child[1].SEF)
|
node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF)
|
||||||
node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF)
|
parent[index] = node
|
||||||
node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF)
|
# Make another pass with the substitution
|
||||||
parent[index] = node
|
self.FoldTree(parent, index)
|
||||||
else:
|
elif nt == '&&':
|
||||||
orchildren = [
|
# Expand to its equivalent a && b -> !(!a | !b)
|
||||||
nr(nt='!',t='integer',ch=[child[0]],SEF=child[0].SEF),
|
orchildren = [
|
||||||
nr(nt='!',t='integer',ch=[child[1]],SEF=child[1].SEF)
|
nr(nt='!', t='integer', ch=[child[0]], SEF=child[0].SEF),
|
||||||
]
|
nr(nt='!', t='integer', ch=[child[1]], SEF=child[1].SEF)
|
||||||
node = nr(nt='|', t='integer', ch=orchildren,
|
]
|
||||||
SEF=child[0].SEF and child[1].SEF)
|
node = nr(nt='|', t='integer', ch=orchildren,
|
||||||
node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF)
|
SEF=child[0].SEF and child[1].SEF)
|
||||||
parent[index] = node
|
node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF)
|
||||||
|
parent[index] = node
|
||||||
# Make another pass with the substitution
|
# Make another pass with the substitution
|
||||||
self.FoldTree(parent, index)
|
self.FoldTree(parent, index)
|
||||||
return
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue