using a local for math.random calls

This commit is contained in:
Paul Liverman III 2018-04-23 02:31:26 -07:00
parent 0980d07eaa
commit 78805a5e42

View File

@ -32,6 +32,7 @@ local math_ceil = math.ceil
local math_atan2 = math.atan2 or math.atan
local math_sqrt = math.sqrt
local math_abs = math.abs
local math_random = math.random
local noop = function()
end
@ -133,12 +134,12 @@ end
function lume.random(a, b)
if not a then a, b = 0, 1 end
if not b then b = 0 end
return a + math.random() * (b - a)
return a + math_random() * (b - a)
end
function lume.randomchoice(t)
return t[math.random(#t)]
return t[math_random(#t)]
end
@ -213,7 +214,7 @@ end
function lume.shuffle(t)
local rtn = {}
for i = 1, #t do
local r = math.random(i)
local r = math_random(i)
if r ~= i then
rtn[i] = rtn[r]
end
@ -677,7 +678,7 @@ end
function lume.uuid()
local fn = function(x)
local r = math.random(16) - 1
local r = math_random(16) - 1
r = (x == "x") and (r + 1) or (r % 4) + 9
return ("0123456789abcdef"):sub(r, r)
end