From 36e9035a3dfeda6f9ca4030bc04dcb13adf5595c Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Fri, 16 May 2014 07:06:22 +1000 Subject: Optimize toBool() a little. --- lib/LSL.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/LSL.lua') diff --git a/lib/LSL.lua b/lib/LSL.lua index 1afc8ec..4ec64b5 100644 --- a/lib/LSL.lua +++ b/lib/LSL.lua @@ -1031,10 +1031,10 @@ end -- Lua really hates 0, it's not false, and it can't be a table index. function LSL.toBool(x) - local v = x - local t = type(v) - if 'boolean' == t then return v end - if 'number' == t then return (v ~= 0) end + local t = type(x) + + if 'boolean' == t then return x end + if 'number' == t then return (x ~= 0) end if 'nil' == t then return false end -- Is an empty string, empty list, zero vector/rotation false? Fucked if I know. return true -- cgit v1.1