mirror of
https://github.com/rxi/shash.git
synced 2024-11-24 08:44:36 +00:00
Use LuaJIT's table.clear
where possible
This commit is contained in:
parent
e761142dee
commit
9004e35d4a
13
shash.lua
13
shash.lua
@ -7,6 +7,15 @@
|
||||
-- under the terms of the MIT license. See LICENSE for details.
|
||||
--
|
||||
|
||||
-- Use LuaJIT's table.clear where possible
|
||||
local ok, table_clear = pcall(require, "table.clear")
|
||||
if not ok then
|
||||
table_clear = function(t)
|
||||
for k, v in pairs(t) do
|
||||
t[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
local floor = math.floor
|
||||
local table_remove = table.remove
|
||||
local table_insert = table.insert
|
||||
@ -196,9 +205,7 @@ local function each_overlapping_entity(self, e, fn, ...)
|
||||
-- Do overlap checks
|
||||
each_overlapping_cell(self, e, each_overlapping_in_cell, e, set, fn, ...)
|
||||
-- Clear set and return to pool
|
||||
for v in pairs(set) do
|
||||
set[v] = nil
|
||||
end
|
||||
table_clear(set)
|
||||
table_insert(self.tablepool, set)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user