In converting level:tug_crate to level_tug_crate (which allows for a substantially more efficient and modestly shorter foreach to replace a for loop elsewhere in the code), I chose to define local self=level to save four cycles at the cost of three tokens; using the global level in all cases incurs an extra two global lookups (at two cycles each). Since this is called in a loop in code generally sus from a performance perspective I think that's the appropriate trade-off but you're welcome to overrule me on this.
Most other changes are "pure wins", improving both performance and tokens, primarily by finding terser ways to express conditions.
I tested this by playing a few levels but please scrutinize this closely to make sure my permuations are as equivalent as I think they are.
As is required in Pico-8 Golf, I'm sacrificing some readability in favor of terseness.
These should be semantically equivalent.
In converting level:tug_crate to level_tug_crate (which allows for a substantially more efficient and modestly shorter foreach to replace a for loop elsewhere in the code), I chose to define `local self=level` to save four cycles at the cost of three tokens; using the global `level` in all cases incurs an extra two global lookups (at two cycles each). Since this is called in a loop in code generally sus from a performance perspective I think that's the appropriate trade-off but you're welcome to overrule me on this.
Most other changes are "pure wins", improving both performance and tokens, primarily by finding terser ways to express conditions.
I tested this by playing a few levels but please scrutinize this closely to make sure my permuations are as equivalent as I think they are.
As is required in Pico-8 Golf, I'm sacrificing some readability in favor of terseness.
The tug_crate conversion is for performance. `foreach(tbl, predefined_func)` is substantially faster than a standard `for` loop using the `all` iterator. However, if the function inside the foreach is defined inline, it's much slower due to closure-construction overhead (even though nothing is being closed over). Converting `tug_crate` to take a table as an argument allows foreach to feed right into it, and it also naturally suggests a rewrite a few lines down to get rid of duplicative listing of `mx0,my0,dmx,dmy`, saving several tokens.
I'm going to take a look at can_move to see if it's worth making iits mx0,my0,dmx,dmy arguments into a table as well.
this is approximately token-neutral but performance-saving. each function parameter makes its call cost worse. When can_move is called inside a loop, we already have a table and we unpack to call can_move; moving the unpack into can_move saves us marshalling cost. It requires us to construct a table in a different spot (where we were not previously doing so) but that spot is not in a loop.
Removed unnecessary variable declarations and conditional cases by using an "assume, alternate, verify assumption" pattern and reusing ax0/ay0 when they would never be referenced again.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
These should be semantically equivalent.
In converting level:tug_crate to level_tug_crate (which allows for a substantially more efficient and modestly shorter foreach to replace a for loop elsewhere in the code), I chose to define
local self=levelto save four cycles at the cost of three tokens; using the globallevelin all cases incurs an extra two global lookups (at two cycles each). Since this is called in a loop in code generally sus from a performance perspective I think that's the appropriate trade-off but you're welcome to overrule me on this.Most other changes are "pure wins", improving both performance and tokens, primarily by finding terser ways to express conditions.
I tested this by playing a few levels but please scrutinize this closely to make sure my permuations are as equivalent as I think they are.
As is required in Pico-8 Golf, I'm sacrificing some readability in favor of terseness.