summaryrefslogtreecommitdiff
path: root/xmake/core/base/table.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-10-28 00:37:30 +0800
committerruki <[email protected]>2021-10-28 00:37:30 +0800
commit020ec323df6377390fe144e8af78dd7cc741ec0b (patch)
tree92ae67e5301eab91ad4e8fd6d8fa074429811b00 /xmake/core/base/table.lua
parentd527a9213c3ac1651dc7f7bea7a2ea91139ed6ff (diff)
improve ml
Diffstat (limited to 'xmake/core/base/table.lua')
-rw-r--r--xmake/core/base/table.lua46
1 files changed, 35 insertions, 11 deletions
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index 4f21ec358..21fa185a0 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -227,21 +227,45 @@ function table.is_dictionary(dict)
return type(dict) == "table" and dict[1] == nil
end
--- does contain the given value in table?
-function table.contains(t, value)
+-- does contain the given values in table?
+-- contains arg1 or arg2 ...
+function table.contains(t, arg1, arg2, ...)
local found = false
- if table.is_array(t) then
- for _, v in ipairs(t) do
- if v == value then
- found = true
- break
+ if arg2 == nil then -- only one value
+ if table.is_array(t) then
+ for _, v in ipairs(t) do
+ if v == arg1 then
+ found = true
+ break
+ end
+ end
+ else
+ for _, v in pairs(t) do
+ if v == arg1 then
+ found = true
+ break
+ end
end
end
else
- for _, v in pairs(t) do
- if v == value then
- found = true
- break
+ local values = {}
+ local args = table.pack(arg1, arg2, ...)
+ for _, arg in ipairs(args) do
+ values[arg] = true
+ end
+ if table.is_array(t) then
+ for _, v in ipairs(t) do
+ if values[v] then
+ found = true
+ break
+ end
+ end
+ else
+ for _, v in pairs(t) do
+ if values[v] then
+ found = true
+ break
+ end
end
end
end