Heavy memory/performance optimizations #1
This commit is contained in:
parent
2b0f1af5cc
commit
3e9e582572
1 changed files with 11 additions and 6 deletions
|
@ -47,7 +47,7 @@ REMOVE_PREFIX = "cbi.rts."
|
|||
-- Loads a CBI map from given file, creating an environment and returns it
|
||||
function load(cbimap, ...)
|
||||
require("luci.fs")
|
||||
require("luci.i18n")
|
||||
local i18n = require "luci.i18n"
|
||||
require("luci.config")
|
||||
require("luci.util")
|
||||
|
||||
|
@ -57,11 +57,16 @@ function load(cbimap, ...)
|
|||
|
||||
luci.i18n.loadc("cbi")
|
||||
|
||||
luci.util.resfenv(func)
|
||||
luci.util.updfenv(func, luci.cbi)
|
||||
luci.util.extfenv(func, "translate", luci.i18n.translate)
|
||||
luci.util.extfenv(func, "translatef", luci.i18n.translatef)
|
||||
luci.util.extfenv(func, "arg", {...})
|
||||
local env = {
|
||||
translate=i18n.translate,
|
||||
translatef=i18n.translatef,
|
||||
arg={...}
|
||||
}
|
||||
|
||||
setfenv(func, setmetatable(env, {__index =
|
||||
function(tbl, key)
|
||||
return rawget(tbl, key) or _M[key] or _G[key]
|
||||
end}))
|
||||
|
||||
local maps = {func()}
|
||||
|
||||
|
|
Loading…
Reference in a new issue