mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Fix bug with tab handling.
Commit 5804a9a
introduced a bug where having the foldtabs option disabled (normal) prevented optimizations of functions. Fix it for good (hopefully). While on it, rename the nofoldtabs option to warntabs, making it default, and use it to disable a warning when there are tabs in a string.
This commit is contained in:
parent
95bd3209be
commit
b7e6e6f7b1
4 changed files with 23 additions and 18 deletions
|
@ -945,14 +945,14 @@ class foldconst(object):
|
|||
else:
|
||||
value = fn(*tuple(arg['value'] for arg in child))
|
||||
if not self.foldtabs:
|
||||
if not self.nofoldtabs:
|
||||
generatesTabs = (
|
||||
isinstance(value, unicode) and '\t' in value
|
||||
or type(value) == list and any(isinstance(x, unicode) and '\t' in x for x in value)
|
||||
)
|
||||
if generatesTabs:
|
||||
warning("Can't optimize call to %s because it would generate a tab character (you can force the optimization with the foldtabs option, or disable this warning with the nofoldtabs option)." % node['name'])
|
||||
return
|
||||
generatesTabs = (
|
||||
isinstance(value, unicode) and '\t' in value
|
||||
or type(value) == list and any(isinstance(x, unicode) and '\t' in x for x in value)
|
||||
)
|
||||
if generatesTabs:
|
||||
if self.warntabs:
|
||||
warning("Can't optimize call to %s because it would generate a tab character (you can force the optimization with the 'foldtabs' option, or disable this warning by disabling the 'warntabs' option)." % node['name'])
|
||||
return
|
||||
parent[index] = {'nt':'CONST', 't':node['t'], 'value':value}
|
||||
except lslfuncs.ELSLCantCompute:
|
||||
# Don't transform the tree if function is not computable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue