save optimization

This commit is contained in:
p.kosyh 2010-07-13 06:42:08 +00:00
parent 5392162de8
commit 76f6550fa4
2 changed files with 19 additions and 1 deletions

View file

@ -115,6 +115,7 @@ function list_check(self, name) -- force using of objects, instead refs
local n = stead.string.format("%s[%d]", name, ii);
v = allocator:new(n);
self[ii] = v;
v.auto_allocated = true;
for_each(v, n, check_list, isList, deref(v));
else
self[ii] = o;
@ -183,6 +184,20 @@ function list_str(self)
return v;
end
function list_save(self, name, h, need)
if self.__modified__ then
local i,v
for i,v in ipairs(self) do -- dump auto objs
if isObject(v) and v.auto_allocated then
v:save(v.key_name, h, true, true);
end
end
h:write(name.." = list({});\n");
need = true;
end
savemembers(h, self, name, need);
end
function obj_str(self)
local i, v, vv, o;
if not isObject(self) then

View file

@ -2002,7 +2002,10 @@ function lifeoff(what)
game.lifes:del(what);
end
function allocator_save(s, name, h, need)
function allocator_save(s, name, h, need, auto)
if s.auto_allocated and not auto then
return
end
if need then
local m = ' = allocator:get("'..name:gsub('"','\\"')..'","'..tostring(s.constructor):gsub('"','\\"')..'");';
h:write(name..m..'\n');