diff --git a/code/controllers/subsystem/garbage.dm b/code/controllers/subsystem/garbage.dm index a8a673aac1e..79fd1d11863 100644 --- a/code/controllers/subsystem/garbage.dm +++ b/code/controllers/subsystem/garbage.dm @@ -136,18 +136,24 @@ SUBSYSTEM_DEF(garbage) lastlevel = level - for(var/refID in queue) - if(!refID) + // The instinct is to use a for in loop here, to walk the entries in the queue + // The trouble is this performs a copy of the queue list, and since this can in theory balloon a LOT + // It's better to just go index by index. It's not a huge deal but it's worth doin IMO + for(var/i in 1 to length(queue)) + var/list/packet = queue[i] + if(length(packet) != 2) count++ if(MC_TICK_CHECK) return continue - var/GCd_at_time = queue[refID] + var/GCd_at_time = packet[2] if(GCd_at_time > cut_off_time) break // Everything else is newer, skip them count++ + var/refID = packet[1] + var/datum/D D = locate(refID) @@ -212,14 +218,12 @@ SUBSYSTEM_DEF(garbage) HardDelete(D) return var/gctime = world.time - var/refid = "\ref[D]" D.gc_destroyed = gctime - var/list/queue = queues[level] - if(queue[refid]) - queue -= refid // Removing any previous references that were GC'd so that the current object will be at the end of the list. - queue[refid] = gctime + var/list/queue = queues[level] + // I hate byond lists so much man + queue[++queue.len] = list("\ref[D]", gctime) //this is mainly to separate things profile wise. /datum/controller/subsystem/garbage/proc/HardDelete(datum/D)