[PATCH] Wasted memory use storing path copies in node tree
[project/luci.git] / libs / web / luasrc / dispatcher.lua
index e29bd52..0162407 100644 (file)
@@ -612,28 +612,23 @@ function node(...)
        return c
 end
 
-function _create_node(path, cache)
+function _create_node(path)
        if #path == 0 then
                return context.tree
        end
 
-       cache = cache or context.treecache
        local name = table.concat(path, ".")
-       local c = cache[name]
+       local c = context.treecache[name]
 
        if not c then
-               local new = {nodes={}, auto=true, path=util.clone(path)}
                local last = table.remove(path)
+               local parent = _create_node(path)
 
-               c = _create_node(path, cache)
-
-               c.nodes[last] = new
-               cache[name] = new
-
-               return new
-       else
-               return c
+               c = {nodes={}, auto=true}
+               parent.nodes[last] = c
+               context.treecache[name] = c
        end
+       return c
 end
 
 -- Subdispatchers --