From e13d4e0e377a5fce26f335c4e7e66db1377a519f Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 20 Dec 2013 18:13:11 -0200 Subject: Use same loop for both arrays --- src/luarocks/cfg.lua | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 0ff8f537..2904146b 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -472,25 +472,16 @@ end -- Use defaults: --- Populate values from 'defaults.variables' in 'variables' if they were not --- already set by user. -if not _M.variables then - _M.variables = {} -end -for k,v in pairs(defaults.variables) do - if not _M.variables[k] then - _M.variables[k] = v +-- Populate some arrays with values from their 'defaults' counterparts +-- if they were not already set by user. +for _, entry in ipairs({"variables", "rocks_provided"}) do + if not _M[entry] then + _M[entry] = {} end -end - --- Populate values from 'defaults.rocks_provided' in 'rocks_provided' if they --- were not already set by user. -if not type(_M.rocks_provided) == "table" then - _M.rocks_provided = {} -end -for k,v in pairs(defaults.rocks_provided) do - if not _M.rocks_provided[k] then - _M.rocks_provided[k] = v + for k,v in pairs(defaults[entry]) do + if not _M[entry][k] then + _M[entry][k] = v + end end end -- cgit v1.2.3-55-g6feb