summaryrefslogtreecommitdiffhomepage
path: root/libs/uvl
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-09-09 15:39:54 +0000
committerSteven Barth <steven@midlink.org>2008-09-09 15:39:54 +0000
commit9ffd02f8d646c561ace0751de23cb40dfa0e0625 (patch)
treeb8c64b31ed745ff8822227a50301ec696150af03 /libs/uvl
parent2d409a35862a735327f8fb5de56d891d81ceee94 (diff)
Main library optimizations #1
Diffstat (limited to 'libs/uvl')
-rw-r--r--libs/uvl/luasrc/uvl.lua33
1 files changed, 13 insertions, 20 deletions
diff --git a/libs/uvl/luasrc/uvl.lua b/libs/uvl/luasrc/uvl.lua
index 36aed217d..f715a027c 100644
--- a/libs/uvl/luasrc/uvl.lua
+++ b/libs/uvl/luasrc/uvl.lua
@@ -432,7 +432,7 @@ end
-- helper function to validate references
local function _ref( c, t )
- local k, n
+ local r, k, n = {}
if c == TYPE_SECTION then
k = "package"
n = 1
@@ -444,7 +444,9 @@ local function _ref( c, t )
n = 3
end
- local r = luci.util.split( t[k], "." )
+ for o in t[k]:gmatch("[^.]+") do
+ r[#r+1] = o
+ end
r[1] = ( #r[1] > 0 and r[1] or scheme:sid() )
if #r ~= n then
@@ -816,22 +818,15 @@ function uvlitem.sid(self)
end
function uvlitem.scheme(self, opt)
- local s
-
+ local s = self.s and self.s.packages
+ s = s and s[self.sref[1]]
if #self.sref == 4 or #self.sref == 3 then
- s = self.s and self.s.packages
- s = s and s[self.sref[1]]
s = s and s.variables
s = s and s[self.sref[2]]
s = s and s[self.sref[3]]
elseif #self.sref == 2 then
- s = self.s and self.s.packages
- s = s and s[self.sref[1]]
s = s and s.sections
s = s and s[self.sref[2]]
- else
- s = self.s and self.s.packages
- s = s and s[self.sref[1]]
end
if s and opt then
@@ -842,16 +837,14 @@ function uvlitem.scheme(self, opt)
end
function uvlitem.config(self, opt)
- local c
+ local c = self.c
- if #self.cref == 4 or #self.cref == 3 then
- c = self.c and self.c[self.cref[2]] or nil
- c = c and c[self.cref[3]] or nil
- elseif #self.cref == 2 then
- c = self.c and self.c[self.cref[2]] or nil
- else
- c = self.c
- end
+ if #self.cref >= 2 and #self.cref <= 4 then
+ c = c and self.c[self.cref[2]] or nil
+ if #self.cref >= 3 then
+ c = c and c[self.cref[3]] or nil
+ end
+ end
if c and opt then
return c[opt]