From 86033f0470210e42b59b479e602f5e3cc15ce419 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Wed, 19 Jan 2022 16:38:06 +0100 Subject: [PATCH] Heap: Localize math.floor & table.insert --- heap.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/heap.lua b/heap.lua index c4a8c15..5bdd7c2 100644 --- a/heap.lua +++ b/heap.lua @@ -1,5 +1,5 @@ -- Localize globals -local math, setmetatable, table = math, setmetatable, table +local math_floor, setmetatable, table_insert = math.floor, setmetatable, table.insert -- Set environment local _ENV = {} @@ -15,12 +15,12 @@ function new(less_than) end function push(self, value) - table.insert(self, value) + table_insert(self, value) local function heapify(index) if index == 1 then return end - local parent = math.floor(index / 2) + local parent = math_floor(index / 2) if self.less_than(self[index], self[parent]) then self[parent], self[index] = self[index], self[parent] heapify(parent)