Comparison

core/moduleapi.lua @ 5053:375ab71e4b37

moduleapi: If path name ends with '-cache' create table as weak (keys and values)
author Matthew Wild <mwild1@gmail.com>
date Mon, 30 Jul 2012 00:40:02 +0100
parent 5024:d25e1b9332cc
child 5077:6c2c8bf36d22
comparison
equal deleted inserted replaced
5052:f1157cce5d7a 5053:375ab71e4b37
153 path = (n_components<#default_path_components and "/" or "")..t_concat(default_path_components, "/", 1, #default_path_components-n_components).."/"..path; 153 path = (n_components<#default_path_components and "/" or "")..t_concat(default_path_components, "/", 1, #default_path_components-n_components).."/"..path;
154 end 154 end
155 local shared = shared_data[path]; 155 local shared = shared_data[path];
156 if not shared then 156 if not shared then
157 shared = {}; 157 shared = {};
158 if path:match("%-cache$") then
159 setmetatable(shared, { __mode = "kv" });
160 end
158 shared_data[path] = shared; 161 shared_data[path] = shared;
159 end 162 end
160 t_insert(data_array, shared); 163 t_insert(data_array, shared);
161 self.shared_data[path] = shared; 164 self.shared_data[path] = shared;
162 end 165 end