Skip to content

Commit

Permalink
Avoid packing arguments in a table.
Browse files Browse the repository at this point in the history
The implementation of coxpcall is based on coroutine.resume which, in
contrast to xpcall, can handle extra arguments since the beginning. So,
packing the arguments in a table is unnecessary and wasteful.
  • Loading branch information
siffiejoe committed Feb 22, 2016
1 parent 66f0ee6 commit 732898e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/coxpcall.lua
Expand Up @@ -76,8 +76,7 @@ function coxpcall(f, err, ...)
else
local res, co = oldpcall(coroutine.create, f)
if not res then
local params = pack(...)
local newf = function() return f(unpack(params, 1, params.n)) end
local newf = function(...) return f(...) end
co = coroutine.create(newf)
end
coromap[co] = current
Expand Down

0 comments on commit 732898e

Please sign in to comment.