Optimization for vararg tables
A vararg table can be virtual. If the vararg table is used only as a base in indexing expressions, the code does not need to create an actual table for it. Instead, it compiles the indexing expressions into direct accesses to the internal vararg data.
This commit is contained in:
@@ -310,8 +310,7 @@ do -- testing presence of second argument
|
||||
local function foo (howtoclose, obj, n)
|
||||
local ca -- copy of 'a' visible inside its close metamethod
|
||||
do
|
||||
local a <close> = func2close(function (...)
|
||||
local t = table.pack(...)
|
||||
local a <close> = func2close(function (... | t)
|
||||
assert(select("#", ...) == n)
|
||||
assert(t.n == n and t[1] == ca and (t.n < 2 or t[2] == obj))
|
||||
ca = 15 -- final value to be returned if howtoclose=="scope"
|
||||
@@ -911,8 +910,7 @@ do
|
||||
|
||||
local extrares -- result from extra yield (if any)
|
||||
|
||||
local function check (body, extra, ...)
|
||||
local t = table.pack(...) -- expected returns
|
||||
local function check (body, extra, ...|t)
|
||||
local co = coroutine.wrap(body)
|
||||
if extra then
|
||||
extrares = co() -- runs until first (extra) yield
|
||||
|
||||
Reference in New Issue
Block a user