Use luajit table.clear properly

Fixes #25
This commit is contained in:
Max Cahill 2021-06-29 14:46:40 +10:00
parent a2c7800290
commit 1de942daa8

View File

@ -256,8 +256,12 @@ function tablex.dedupe(t)
return r return r
end end
--(might already exist depending on luajit) --(might already exist depending on environment)
if not tablex.clear then if not tablex.clear then
local imported
--pull in from luajit if possible
imported, tablex.clear = pcall(require, "table.clear")
if not imported then
--remove all values from a table --remove all values from a table
--useful when multiple references are being held --useful when multiple references are being held
--so you cannot just create a new table --so you cannot just create a new table
@ -270,6 +274,7 @@ if not tablex.clear then
end end
end end
end end
end
--note: --note:
-- copies and overlays are currently not satisfactory -- copies and overlays are currently not satisfactory