Save .996s of init time by not initializing shards rods and coil in every single window, and a one line check in turf/Initialize (#71046)

/obj/machinery/door/window/Initialize lowers by 221.81ms.

/turf/Initialize lowers by 775ms.
vis_contents is stupid man
This commit is contained in:
Mothblocks
2022-11-06 22:17:22 -08:00
committed by GitHub
parent 356d12db7e
commit ad744e7899
4 changed files with 24 additions and 17 deletions
+4 -1
View File
@@ -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)
+4 -1
View File
@@ -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)
+10 -12
View File
@@ -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)
+6 -3
View File
@@ -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