save optimization
This commit is contained in:
parent
5392162de8
commit
76f6550fa4
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue