summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-09-05 18:34:46 +0000
committerSteven Barth <steven@midlink.org>2008-09-05 18:34:46 +0000
commit3e9e582572bbb893aba4240708b7fabd3a2accaa (patch)
tree8881cb929822140caf4d1f0af844aa161e028b37 /libs
parent2b0f1af5cc40a26b2111a88815f901652753a56f (diff)
Heavy memory/performance optimizations #1
Diffstat (limited to 'libs')
-rw-r--r--libs/cbi/luasrc/cbi.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index 3a6c6d7aa..ac8d8b5b3 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -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()}