mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
New option to optimize float-to-int conversion separately from sign optim.
The option is optfloats. Add support everywhere.
This commit is contained in:
parent
efc7f4406a
commit
3ac4bc4f0d
2 changed files with 9 additions and 6 deletions
|
@ -41,7 +41,7 @@ class outscript(object):
|
|||
return '((integer)' + str(value) + ')'
|
||||
return str(value)
|
||||
if tvalue == float:
|
||||
if self.optsigns and value.is_integer() and -2147483648.0 <= value < 2147483648.0:
|
||||
if self.optfloats and value.is_integer() and -2147483648.0 <= value < 2147483648.0:
|
||||
if self.globalmode and not self.listmode:
|
||||
return str(int(value))
|
||||
elif not self.globalmode:
|
||||
|
@ -295,12 +295,13 @@ class outscript(object):
|
|||
|
||||
return self.dent() + self.OutExpr(node) + ';\n'
|
||||
|
||||
def output(self, treesymtab, options = ('optsigns',)):
|
||||
def output(self, treesymtab, options = ('optsigns','optfloats')):
|
||||
# Build a sorted list of dict entries
|
||||
self.tree, self.symtab = treesymtab
|
||||
|
||||
# Optimize signs
|
||||
self.optsigns = 'optsigns' in options
|
||||
self.optfloats = 'optfloats' in options
|
||||
|
||||
ret = ''
|
||||
self.indent = ' '
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue