Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions the-tiny-lua-compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3927,13 +3927,11 @@ function VirtualMachine:executeClosure(...)
-- OP_CONCAT [A, B, C] R(A) := R(B).. ... ..R(C)
-- Concatenate a range of registers and store the result in a register.
elseif opcode == "CONCAT" then
local values = {}
for reg = b, c do
table.insert(values, stack[reg])
for reg = c - 1, b, -1 do
-- We cannot use table.concat as it does not call metamethods
stack[reg] = stack[reg] .. stack[reg + 1]
end

-- Optimization: use table.concat for efficient string concatenation.
stack[a] = table.concat(values)
stack[a] = stack[b]

-- OP_JMP [A, sBx] pc+=sBx
-- Jump to a new instruction offset.
Expand Down