From b3861e0ec70ad94f925f196564e6a20e509ab9c4 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 12 Aug 2011 11:04:42 +0000 Subject: [PATCH] [PATCH] Wasted memory use storing path copies in node tree When creating the node tree, every node stores a copy of its full path table. e.g. for node("admin.network.wireless"), node.path = { "admin", "network", "wireless" } This value is not used anywhere, and likely may be from before the addition of the treecache lookup table? In any instance, I've searched high and low and see nothing ever referencing any node's path via the path member. It eats a good chunk of memory though and as such I believe it should be removed. I've tested every page in the admin-full module after removing it and all seem to function properly. --- libs/web/luasrc/dispatcher.lua | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index e29bd52bc8..0162407cd5 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -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 -- -- 2.30.2