Main library optimizations #1
This commit is contained in:
parent
2d409a3586
commit
9ffd02f8d6
1 changed files with 13 additions and 20 deletions
|
@ -432,7 +432,7 @@ end
|
||||||
|
|
||||||
-- helper function to validate references
|
-- helper function to validate references
|
||||||
local function _ref( c, t )
|
local function _ref( c, t )
|
||||||
local k, n
|
local r, k, n = {}
|
||||||
if c == TYPE_SECTION then
|
if c == TYPE_SECTION then
|
||||||
k = "package"
|
k = "package"
|
||||||
n = 1
|
n = 1
|
||||||
|
@ -444,7 +444,9 @@ local function _ref( c, t )
|
||||||
n = 3
|
n = 3
|
||||||
end
|
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() )
|
r[1] = ( #r[1] > 0 and r[1] or scheme:sid() )
|
||||||
|
|
||||||
if #r ~= n then
|
if #r ~= n then
|
||||||
|
@ -816,22 +818,15 @@ function uvlitem.sid(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function uvlitem.scheme(self, opt)
|
function uvlitem.scheme(self, opt)
|
||||||
local s
|
local s = self.s and self.s.packages
|
||||||
|
|
||||||
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[self.sref[1]]
|
||||||
|
if #self.sref == 4 or #self.sref == 3 then
|
||||||
s = s and s.variables
|
s = s and s.variables
|
||||||
s = s and s[self.sref[2]]
|
s = s and s[self.sref[2]]
|
||||||
s = s and s[self.sref[3]]
|
s = s and s[self.sref[3]]
|
||||||
elseif #self.sref == 2 then
|
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.sections
|
||||||
s = s and s[self.sref[2]]
|
s = s and s[self.sref[2]]
|
||||||
else
|
|
||||||
s = self.s and self.s.packages
|
|
||||||
s = s and s[self.sref[1]]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if s and opt then
|
if s and opt then
|
||||||
|
@ -842,15 +837,13 @@ function uvlitem.scheme(self, opt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function uvlitem.config(self, opt)
|
function uvlitem.config(self, opt)
|
||||||
local c
|
local c = self.c
|
||||||
|
|
||||||
if #self.cref == 4 or #self.cref == 3 then
|
if #self.cref >= 2 and #self.cref <= 4 then
|
||||||
c = self.c and self.c[self.cref[2]] or nil
|
c = c and self.c[self.cref[2]] or nil
|
||||||
|
if #self.cref >= 3 then
|
||||||
c = c and c[self.cref[3]] or nil
|
c = c and c[self.cref[3]] or nil
|
||||||
elseif #self.cref == 2 then
|
end
|
||||||
c = self.c and self.c[self.cref[2]] or nil
|
|
||||||
else
|
|
||||||
c = self.c
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if c and opt then
|
if c and opt then
|
||||||
|
|
Loading…
Reference in a new issue