From f354bba3b27f3a33c4de7ba3aa541045d6b17e34 Mon Sep 17 00:00:00 2001 From: Lupus590 Date: Fri, 30 Sep 2022 06:11:13 +0100 Subject: [PATCH] reorder if statements (#11) Lua supports short-circuit evaluation, we can use it to speed up execution in some cases. --- netrequire.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netrequire.lua b/netrequire.lua index c9178bc..3b7bb75 100644 --- a/netrequire.lua +++ b/netrequire.lua @@ -9,10 +9,10 @@ local function netrequire(_name, alwaysDownload, ...) name = _name end - if fs.exists(fs.combine(DL_path .. "/require", name)) and not alwaysDownload then + if (not alwaysDownload) and fs.exists(fs.combine(DL_path .. "/require", name)) then return loadfile(fs.combine(DL_path .. "/require", name))(...) - elseif fs.exists(fs.combine(DL_path .. "/loadAPI", name)) and not alwaysDownload then + elseif (not alwaysDownload) and fs.exists(fs.combine(DL_path .. "/loadAPI", name)) then os.loadAPI(fs.combine(DL_path .. "/loadAPI", name)) return _ENV[fs.getName(name)]