mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Minor details
Assert that it can't be key where we say it can't, and that it is integer where we say it must. Adjust some comments.
This commit is contained in:
parent
a33dc8540f
commit
ac254efb77
1 changed files with 7 additions and 2 deletions
|
@ -857,9 +857,11 @@ class foldconst(object):
|
|||
return
|
||||
|
||||
# Can't be key, as no combo of addition operands returns key
|
||||
# All these types evaluate to boolean False when they are
|
||||
# the neutral addition element.
|
||||
assert optype != 'key'
|
||||
|
||||
if optype in ('string', 'float', 'list'):
|
||||
# All these types evaluate to boolean False when they are
|
||||
# the neutral addition element.
|
||||
if lnt == 'CONST' and not lval.value:
|
||||
# 0. + expr -> expr
|
||||
# "" + expr -> expr
|
||||
|
@ -928,12 +930,15 @@ class foldconst(object):
|
|||
type(lval.value)]
|
||||
return
|
||||
|
||||
# Nothing else to do with addition of float, string or list
|
||||
return
|
||||
|
||||
# Must be two integers. This allows for a number of
|
||||
# optimizations. First the most obvious ones.
|
||||
assert optype == 'integer' # just to make sure
|
||||
|
||||
if lnt == 'CONST' and lval.value == 0:
|
||||
# 0 + x = x
|
||||
parent[index] = rval
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue