Optimized uvl.dependencies
[project/luci.git] / libs / uvl / luasrc / uvl / dependencies.lua
index ed5770f..d19149e 100644 (file)
@@ -14,9 +14,17 @@ $Id$
 
 ]]--
 
-module( "luci.uvl.dependencies", package.seeall )
+local uvl = require "luci.uvl"
+local ERR = require "luci.uvl.errors"
+local util = require "luci.util"
+local table = require "table"
+
+local type, unpack = type, unpack
+local ipairs, pairs = ipairs, pairs
+
+module "luci.uvl.dependencies"
+
 
-local ERR = luci.uvl.errors
 
 function _parse_reference( r, c, s, o )
        local ref  = { }
@@ -27,7 +35,7 @@ function _parse_reference( r, c, s, o )
        }
 
        for v in r:gmatch("[^.]+") do
-               table.insert(ref, (v:gsub( "%$(.+)", vars )))
+               ref[#ref+1] = (v:gsub( "%$(.+)", vars ))
        end
        
        if #ref < 2 then
@@ -43,7 +51,7 @@ end
 function _serialize_dependency( dep, v )
        local str
 
-       for k, v in luci.util.spairs( dep,
+       for k, v in util.spairs( dep,
                function(a,b)
                        a = ( type(dep[a]) ~= "boolean" and "_" or "" ) .. a
                        b = ( type(dep[b]) ~= "boolean" and "_" or "" ) .. b
@@ -81,7 +89,7 @@ function check( self, object, nodeps )
                                        return false, derr:child(ERR.SME_BADDEP(object,k))
                                end
 
-                               local option = luci.uvl.option( self, object.c, unpack(ref) )
+                               local option = uvl.option( self, object.c, unpack(ref) )
 
                                valid, err = self:_validate_option( option, true )
                                if valid then