Skip to content

Commit

Permalink
Simplify min function, no need for a loop or table allocation.
Browse files Browse the repository at this point in the history
  • Loading branch information
profan committed Jul 16, 2017
1 parent 7e1fa4f commit 59361e8
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions bk-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ local function lazy_copy(t1)

end

local function min(...)
local function min(a, b, c)

local args = {...}
local min_val = args[1]
local min_val = a

for i=1, #args do
if min_val > args[i] then
min_val = args[i]
end
end
if b < min_val then min_val = b end
if c < min_val then min_val = c end

return min_val

Expand Down

0 comments on commit 59361e8

Please sign in to comment.