mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-02 08:08:20 +00:00
Well, within reasonable limits. For break, it's explained in the code. If the block is empty of actual code (code that generates output), then the break position is eliminated. For default, if the default label is at the top of the block, the jump and the label are both eliminated. This check doesn't include verifying that there are other non-code-generating statements in between, so there's room for improvement (added corresponding TODO item). This way, we're on par with FS, in case someone (ab)used the FS brokeness when the 'default' label was absent. All one has to do now is add the default label at the top, and the generated code will be the same as it was in FS when abusing that bug, with no extra burden. Example: In FS, the code at the top acted as default and there was no jump for it: default { timer() { switch(1) { 0; case 1: 1; } }} This generated roughly: default { timer() { { if (1 == 1) jump CASE_1; 0; @CASE_1; 1; } }} In this system, it would trigger an error by default. To obtain the FS behaviour, the scripter can do instead: default { timer() { switch(1) { default: 0; case 1: 1; } }} Thanks to this optimization, the code will be the same as in FS. Without it, an extra default label and corresponding jump would be present. |
||
---|---|---|
.. | ||
__init__.py | ||
lslbasefuncs.py | ||
lslcommon.py | ||
lsldeadcode.py | ||
lslextrafuncs.py | ||
lslfoldconst.py | ||
lslfuncparams.py | ||
lslfuncs.py | ||
lsljson.py | ||
lsloptimizer.py | ||
lsloutput.py | ||
lslparse.py | ||
lslrenamer.py |