mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Use CompareTrees to optimize the == operator.
Now we can.
This commit is contained in:
parent
e6b23a2d7a
commit
dc117c2cbf
1 changed files with 5 additions and 9 deletions
|
@ -1084,15 +1084,11 @@ class foldconst(object):
|
||||||
del child
|
del child
|
||||||
self.FoldTree(parent, index)
|
self.FoldTree(parent, index)
|
||||||
return
|
return
|
||||||
# While this is tempting, it can only be done for identifiers.
|
if self.CompareTrees(child[0], child[1]):
|
||||||
# Counterexample: llFrand(1) == llFrand(1) would
|
# a == a -> 1
|
||||||
# almost always return FALSE. After CompareTrees is fixed,
|
parent[index] = {'nt':'CONST', 't':'integer', 'value':1,
|
||||||
# we can reinstate it.
|
'SEF':True}
|
||||||
#if self.CompareTrees(child[0], child[1]):
|
return
|
||||||
# # a == a -> 1
|
|
||||||
# parent[index] = {'nt':'CONST', 't':'integer', 'value':1,
|
|
||||||
# 'SEF':True}
|
|
||||||
# return
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if nt in ('<=', '>=') or nt == '!=' and child[0]['t'] != 'list':
|
if nt in ('<=', '>=') or nt == '!=' and child[0]['t'] != 'list':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue