diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2011-08-12 11:04:42 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2011-08-12 11:04:42 +0000 |
commit | b3861e0ec70ad94f925f196564e6a20e509ab9c4 (patch) | |
tree | 3d8b30d5b31eed922dee465ad41b8b7eff006abd /libs/web/luasrc | |
parent | 69ba2e55a130a86ebd8988ab404a91e42a27dac9 (diff) |
[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.
Diffstat (limited to 'libs/web/luasrc')
-rw-r--r-- | libs/web/luasrc/dispatcher.lua | 19 |
1 files 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 -- |