diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 1f23358a899..162943af814 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -335,7 +335,10 @@ orbiters = null // The component is attached to us normaly and will be deleted elsewhere - LAZYCLEARLIST(overlays) + // Checking length(overlays) before cutting has significant speed benefits + if (length(overlays)) + overlays.Cut() + LAZYNULL(managed_overlays) QDEL_NULL(light) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index a5f91aca4ca..c04b6d3c099 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -195,7 +195,10 @@ vis_locs = null //clears this atom out of all viscontents - vis_contents.Cut() + + // Checking length(vis_contents) before cutting has significant speed benefits + if (length(vis_contents)) + vis_contents.Cut() /atom/movable/proc/update_emissive_block() if(!blocks_emissive) diff --git a/code/game/machinery/doors/windowdoor.dm b/code/game/machinery/doors/windowdoor.dm index c6cc40a78f9..faa1defe7cf 100644 --- a/code/game/machinery/doors/windowdoor.dm +++ b/code/game/machinery/doors/windowdoor.dm @@ -22,7 +22,6 @@ var/shards = 2 var/rods = 2 var/cable = 1 - var/list/debris = list() var/associated_lift = null /obj/machinery/door/window/Initialize(mapload, set_dir, unres_sides) @@ -34,12 +33,6 @@ if(LAZYLEN(req_access)) icon_state = "[icon_state]" base_state = icon_state - for(var/i in 1 to shards) - debris += new /obj/item/shard(src) - if(rods) - debris += new /obj/item/stack/rods(src, rods) - if(cable) - debris += new /obj/item/stack/cable_coil(src, cable) if(unres_sides) //remove unres_sides from directions it can't be bumped from @@ -66,7 +59,6 @@ /obj/machinery/door/window/Destroy() set_density(FALSE) - QDEL_LIST(debris) if(atom_integrity == 0) playsound(src, SFX_SHATTER, 70, TRUE) electronics = null @@ -251,12 +243,18 @@ /obj/machinery/door/window/deconstruct(disassembled = TRUE) if(!(flags_1 & NODECONSTRUCT_1) && !disassembled) - for(var/obj/fragment in debris) - fragment.forceMove(get_turf(src)) - transfer_fingerprints_to(fragment) - debris -= fragment + for(var/i in 1 to shards) + drop_debris(new /obj/item/shard(src)) + if(rods) + drop_debris(new /obj/item/stack/rods(src, rods)) + if(cable) + drop_debris(new /obj/item/stack/cable_coil(src, cable)) qdel(src) +/obj/machinery/door/window/proc/drop_debris(obj/item/debris) + debris.forceMove(loc) + transfer_fingerprints_to(debris) + /obj/machinery/door/window/narsie_act() add_atom_colour("#7D1919", FIXED_COLOUR_PRIORITY) diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 9fffa9b0e47..1df777ce2e1 100755 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -117,8 +117,10 @@ GLOBAL_LIST_EMPTY(station_turfs) if(T) T.multiz_turf_new(src, UP) - // by default, vis_contents is inherited from the turf that was here before - vis_contents.Cut() + // by default, vis_contents is inherited from the turf that was here before. + // Checking length(vis_contents) in a proc this hot has huge wins for performance. + if (length(vis_contents)) + vis_contents.Cut() assemble_baseturfs() @@ -204,7 +206,8 @@ GLOBAL_LIST_EMPTY(station_turfs) requires_activation = FALSE ..() - vis_contents.Cut() + if (length(vis_contents)) + vis_contents.Cut() /// WARNING WARNING /// Turfs DO NOT lose their signals when they get replaced, REMEMBER THIS