summaryrefslogtreecommitdiff
path: root/xmake/core/base/table.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-03-02 23:18:40 +0800
committerruki <[email protected]>2022-03-02 23:18:40 +0800
commit6026401e3bc55e0b5974c0aa18aefe4d7135fe89 (patch)
tree435735b6009ece189bda720db95ceda0f69cb928 /xmake/core/base/table.lua
parent0654d3ea2b7a9063adadd6b3a2c5fe2b0ff7883f (diff)
improve table.wrap
Diffstat (limited to 'xmake/core/base/table.lua')
-rw-r--r--xmake/core/base/table.lua10
1 files changed, 3 insertions, 7 deletions
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index 2cf617f3b..1c19f588d 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -165,13 +165,9 @@ end
-- copy the table to self
function table.copy2(self, copied)
-
- -- clear self first
+ assert(type(copied) == "table")
table.clear(self)
-
- -- copy it
- copied = copied or {}
- for k, v in pairs(table.wrap(copied)) do
+ for k, v in pairs(copied) do
self[k] = v
end
end
@@ -327,7 +323,7 @@ function table.wrap(object)
if nil == object then
return {}
end
- if type(object) ~= "table" then
+ if type(object) ~= "table" or getmetatable(object) then -- maybe object, we need wrap it too
return {object}
end
return object