mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Fix order change in comparisons when one side is not SEF.
The comment was wrong anyway. If one side changes x and the other side uses x, then order is still important, no matter whether one side is SEF. But the reversal is safe when one side is a constant, so we still perform it, to enable optimization of some important cases.
This commit is contained in:
parent
106bb81543
commit
c0176ad738
1 changed files with 3 additions and 2 deletions
|
@ -1158,10 +1158,11 @@ class foldconst(object):
|
|||
self.FoldTree(parent, index)
|
||||
return
|
||||
|
||||
if nt == '>':
|
||||
if nt == '>' and ('SEF' in child[0] and 'SEF' in child[1]
|
||||
or child[0]['nt'] == 'CONST' or child[1]['nt'] == 'CONST'
|
||||
):
|
||||
# Invert the inequalities to avoid doubling the cases to check.
|
||||
# a>b -> b<a
|
||||
# FIXME: This is only possible if at most one is non-SEF.
|
||||
nt = node['nt'] = '<'
|
||||
child[1], child[0] = child[0], child[1]
|
||||
# fall through to check for '<'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue