The current implementation builds the result string by concatenating one element at a time in a loop. Since Lua strings are immutable, each `+` allocates a new string — so joining a list of n elements does n allocations of increasing size, which is O(n²) in total.
For small lists this is fine. For anything large it gets slow fast.
The fix is to collect elements into a Lua table and call `table.concat` at the end, which is what Lua itself recommends for this pattern. A `lua {}` body makes this easy to implement without touching the codegen.
The current implementation builds the result string by concatenating one element at a time in a loop. Since Lua strings are immutable, each `+` allocates a new string — so joining a list of n elements does n allocations of increasing size, which is O(n²) in total.
For small lists this is fine. For anything large it gets slow fast.
The fix is to collect elements into a Lua table and call `table.concat` at the end, which is what Lua itself recommends for this pattern. A `lua {}` body makes this easy to implement without touching the codegen.