diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2018-04-01 00:22:51 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2018-04-01 00:22:51 +0000 |
commit | 8d21763e0821ec56f62b3fc83137220eeca9fbc2 (patch) | |
tree | 7d3aac65ae2af01fd2f5de791b70749a40d8f96c /stand/lua/config.lua | |
parent | 9994e26f370048742926bccaafb976e479d504e4 (diff) | |
download | src-8d21763e0821ec56f62b3fc83137220eeca9fbc2.tar.gz src-8d21763e0821ec56f62b3fc83137220eeca9fbc2.zip |
lualoader: Simplify some expressions
- No need for a 'goto' when our entire loop body is then wrapped in a
conditional.
- No need to leave commented out prints laying around
- If an expression is clearly going to be either nil or an expression that
isn't likely to be a boolean, we might as well use `or` to specify a
default value for the expression. e.g. `loader.getenv(...) or "no"`
Notes
Notes:
svn path=/head/; revision=331857
Diffstat (limited to 'stand/lua/config.lua')
-rw-r--r-- | stand/lua/config.lua | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/stand/lua/config.lua b/stand/lua/config.lua index 419ebb0540e2..040ce790ea41 100644 --- a/stand/lua/config.lua +++ b/stand/lua/config.lua @@ -205,10 +205,7 @@ local function loadModule(mod, silent) local status = true local pstatus for k, v in pairs(mod) do - if v.load == nil then - goto continue - end - if v.load:lower() == "yes" then + if v.load ~= nil and v.load:lower() == "yes" then local str = "load " if v.flags ~= nil then str = str .. v.flags .. " " @@ -247,12 +244,7 @@ local function loadModule(mod, silent) status = status and pstatus end --- else --- if not silent then --- print("Skipping module '". . k .. "'") --- end end - ::continue:: end return status @@ -272,11 +264,8 @@ local function readFile(name, silent) -- We might have read in the whole file, this won't be needed any more. io.close(f) - if text == nil then - if not silent then - print(MSG_FAILREADCFG:format(name)) - end - return nil + if text == nil and not silent then + print(MSG_FAILREADCFG:format(name)) end return text end @@ -322,11 +311,7 @@ config.verbose = false -- The first item in every carousel is always the default item. function config.getCarouselIndex(id) - local val = carousel_choices[id] - if val == nil then - return 1 - end - return val + return carousel_choices[id] or 1 end function config.setCarouselIndex(id, idx) @@ -498,10 +483,7 @@ function config.load(file) -- Cache the provided module_path at load time for later use config.module_path = loader.getenv("module_path") - local verbose = loader.getenv("verbose_loading") - if verbose == nil then - verbose = "no" - end + local verbose = loader.getenv("verbose_loading") or "no" config.verbose = verbose:lower() == "yes" end |