Pooling Update from TG

Ports https://github.com/tgstation/-tg-station/pull/13279.
This commit is contained in:
PsiOmegaDelta
2016-01-08 14:39:42 +01:00
parent a89c066905
commit 875d8455f0

View File

@@ -94,17 +94,32 @@ var/global/list/GlobalPool = list()
loc = args
..()
/datum/proc/ResetVars(var/list/exclude = list())
var/list/excluded = list("animate_movement", "loc", "locs", "parent_type", "vars", "verbs", "type") + exclude
var/list/exclude = list("animate_movement", "contents", "loc", "locs", "parent_type", "vars", "verbs", "type")
var/list/pooledvariables = list()
//thanks to clusterfack @ /vg/station for these two procs
/datum/proc/createVariables()
pooledvariables[type] = new/list()
var/list/exclude = global.exclude + args
for(var/V in vars)
if(V in excluded)
for(var/key in vars)
if(key in exclude)
continue
pooledvariables[type][key] = initial(vars[key])
vars[V] = initial(vars[V])
/datum/proc/ResetVars()
if(!pooledvariables[type])
createVariables(args)
for(var/key in pooledvariables[type])
vars[key] = pooledvariables[type][key]
/atom/movable/ResetVars()
..()
vars["loc"] = null
loc = null
contents = initial(contents) //something is really wrong if this object still has stuff in it by this point
/image/ResetVars()
..()
loc = null
#undef ATOM_POOL_COUNT