summaryrefslogtreecommitdiff
path: root/xmake/core/base/table.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core/base/table.lua')
-rw-r--r--xmake/core/base/table.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index 509082f5c..328bd9f6c 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -335,6 +335,7 @@ function table.imap(arr, mapper)
return newarr
end
+-- reverse table values
function table.reverse(arr)
assert(arr)
@@ -347,5 +348,26 @@ function table.reverse(arr)
return revarr
end
+-- move values of table(a1) to table(a2)
+--
+-- disable the builtin implementation for android termux/arm64, it will crash when calling `table.move({1, 1}, 1, 2, 1, {})`
+--
+-- @see https://github.com/xmake-io/xmake/pull/667#issuecomment-575859604
+--
+if xmake._ARCH:startswith("arm") then
+ function table.move(a1, f, e, t, a2)
+ if a2 == nil then a2 = a1 end
+ if e >= f then
+ local d = t - f
+ if t > e or t <= f or a2 ~= a1 then
+ for i = f, e do a2[i + d] = a1[i] end
+ else
+ for i = e, f, -1 do a2[i + d] = a1[i] end
+ end
+ end
+ return a2
+ end
+end
+
-- return module: table
return table