mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Delete statements in a {} block when they are SEF
This is probably equivalent to what we did, as FoldStmt changes SEF statements to ';' statements, but it's simpler.
This commit is contained in:
parent
caf50c4e14
commit
a93ea0ca19
1 changed files with 4 additions and 3 deletions
|
@ -1578,17 +1578,18 @@ class foldconst(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
if nt == '{}':
|
if nt == '{}':
|
||||||
|
# Remove SEF statements, and mark as SEF if it ends up empty
|
||||||
idx = 0
|
idx = 0
|
||||||
issef = True
|
issef = True
|
||||||
while idx < len(child):
|
while idx < len(child):
|
||||||
self.FoldTree(child, idx)
|
self.FoldTree(child, idx)
|
||||||
self.FoldStmt(child, idx)
|
self.FoldStmt(child, idx)
|
||||||
issef = issef and child[idx].SEF
|
if child[idx].SEF:
|
||||||
if child[idx].nt == ';' \
|
# SEF statements can be removed
|
||||||
or child[idx].nt == '{}' and not child[idx].ch:
|
|
||||||
del child[idx]
|
del child[idx]
|
||||||
else:
|
else:
|
||||||
idx += 1
|
idx += 1
|
||||||
|
issef = False
|
||||||
if issef:
|
if issef:
|
||||||
node.SEF = True
|
node.SEF = True
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue