From ec2cc20a6ba9343107dc33360c98ae865b139d60 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Sat, 9 Feb 2013 22:04:18 +0100 Subject: [PATCH] Better check if cell is empty in Hash:draw() --- spatialhash.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spatialhash.lua b/spatialhash.lua index 4643922..0d8118a 100644 --- a/spatialhash.lua +++ b/spatialhash.lua @@ -141,9 +141,8 @@ function Spatialhash:draw(how, show_empty, print_key) if show_empty == nil then show_empty = true end for k1,v in pairs(self.cells) do for k2,cell in pairs(v) do - local empty = true - (function() for _ in pairs(cell) do empty = false; return end end)() - if show_empty or not empty then + local is_empty = (next(cell) == nil) + if show_empty or not is_empty then local x = k1 * self.cell_size local y = k2 * self.cell_size love.graphics.rectangle(how or 'line', x,y, self.cell_size, self.cell_size)