mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 07:08:00 +01:00
Save 0.4s by shaving off a lot of smaller init costs (#71007)
Starts shaving off a lot of less than 0.1s performance killers by, in nearly every case, just writing better code. Numbers are amount saved. - /obj/machinery/bluespace_vendor/LateInitialize -> 29.4ms Changes a loop over all machines to a specialized list. - /obj/structure/table/glass/Initialize -> 42.53ms Stops every table from initializing glass shards and table frames before any destruction. - /obj/structure/chair/Initialize -> 24.64ms Removes an unnecessary addtimer that existed for chairs that weren't anchored in emergency shuttles. Didn't do anything. - /datum/orderable_item/New -> 44.3ms Instead of initializing every item to get its desc, just uses initial. Added a unit test to make sure none are dynamic. - /obj/machinery/computer/slot_machine/Initialize -> 26.19ms Currently goes through every coin subtype, creates it, calls a proc, then qdels it. Changes that to only run once. Could be optimized further by making the coin info on a datum to avoid creating the object, but it currently sits at 7.82ms, far below worth caring about for now. - /obj/machinery/door_buttons/airlock_controller/findObjsByTag -> 3.51ms Loops over just doors instead of typechecking airlock in machines. - /obj/structure/closet/Initialize -> 60.57ms Moves the code for taking everything on the tile from a next-tick timer to LateInitialize. - /obj/machinery/rnd/experimentor/Initialize -> 36.92ms Changes a list that is generated by going through every item in the game and getting information from a large amount of them to only run when needed. - /obj/structure/tank_dispenser/Initialize -> 20.81ms No longer initializes every tank in it right away, only when needed. - /obj/machinery/telecomms/LateInitialize -> 16.63ms Removes `urange` to instead just loop over telecomms machines and check distance. There's not that many of them. - /mob/living/simple_animal/hostile/carp/cayenne/Initialize -> 3.17ms Defers a GAGS overlay creation until its needed. BTW GAGS is *horrendous* on init costs, and is the root cause for a lot of pretty terrible performance. I investigated precompiling but the gains weren't crazy, but likely could be the more stuff is GAGS'd. - /turf/open/floor/engine/cult/Initialize -> 14.64ms Temporary visual effect that is created is no longer done on mapload, since nobody will see it. - /datum/techweb/specialized/autounlocking/proc/autounlock -> 5.55ms Changes some loops to shorter checks. This whole proc is pretty bad and it's still 14.21ms for 17 calls. - /matrix/New -> 13.41ms - /matrix/proc/Translate -> 42.06ms ~~Changed the mineral matrice to only generate once, then take it from a static.~~ An extra ~0.05s taken off by avoiding setting icon and transform every Initialize.
This commit is contained in:
@@ -24,8 +24,6 @@
|
||||
|
||||
/obj/structure/chair/Initialize(mapload)
|
||||
. = ..()
|
||||
if(!anchored) //why would you put these on the shuttle?
|
||||
addtimer(CALLBACK(src, .proc/RemoveFromLatejoin), 0)
|
||||
if(prob(0.2))
|
||||
name = "tactical [name]"
|
||||
MakeRotate()
|
||||
@@ -35,11 +33,8 @@
|
||||
AddComponent(/datum/component/simple_rotation, ROTATION_IGNORE_ANCHORED|ROTATION_GHOSTS_ALLOWED)
|
||||
|
||||
/obj/structure/chair/Destroy()
|
||||
RemoveFromLatejoin()
|
||||
return ..()
|
||||
|
||||
/obj/structure/chair/proc/RemoveFromLatejoin()
|
||||
SSjob.latejoin_trackers -= src //These may be here due to the arrivals shuttle
|
||||
return ..()
|
||||
|
||||
/obj/structure/chair/deconstruct(disassembled)
|
||||
// If we have materials, and don't have the NOCONSTRUCT flag
|
||||
|
||||
@@ -71,9 +71,12 @@
|
||||
var/contents_initialized = FALSE
|
||||
|
||||
/obj/structure/closet/Initialize(mapload)
|
||||
if(mapload && !opened) // if closed, any item at the crate's loc is put in the contents
|
||||
addtimer(CALLBACK(src, .proc/take_contents, TRUE), 0)
|
||||
. = ..()
|
||||
|
||||
// if closed, any item at the crate's loc is put in the contents
|
||||
if (mapload && !opened)
|
||||
. = INITIALIZE_HINT_LATELOAD
|
||||
|
||||
update_appearance()
|
||||
populate_contents_immediate()
|
||||
var/static/list/loc_connections = list(
|
||||
@@ -82,6 +85,11 @@
|
||||
)
|
||||
AddElement(/datum/element/connect_loc, loc_connections)
|
||||
|
||||
/obj/structure/closet/LateInitialize()
|
||||
. = ..()
|
||||
|
||||
take_contents()
|
||||
|
||||
//USE THIS TO FILL IT, NOT INITIALIZE OR NEW
|
||||
/obj/structure/closet/proc/PopulateContents()
|
||||
SEND_SIGNAL(src, COMSIG_CLOSET_POPULATE_CONTENTS)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
layer = TABLE_LAYER
|
||||
var/frame = /obj/structure/table_frame
|
||||
var/framestack = /obj/item/stack/rods
|
||||
var/glass_shard_type = /obj/item/shard
|
||||
var/buildstack = /obj/item/stack/sheet/iron
|
||||
var/busy = FALSE
|
||||
var/buildstackamount = 1
|
||||
@@ -391,24 +392,14 @@
|
||||
max_integrity = 70
|
||||
resistance_flags = ACID_PROOF
|
||||
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, BIO = 0, FIRE = 80, ACID = 100)
|
||||
var/list/debris = list()
|
||||
|
||||
/obj/structure/table/glass/Initialize(mapload)
|
||||
. = ..()
|
||||
debris += new frame
|
||||
if(buildstack == /obj/item/stack/sheet/plasmaglass)
|
||||
debris += new /obj/item/shard/plasma
|
||||
else
|
||||
debris += new /obj/item/shard
|
||||
var/static/list/loc_connections = list(
|
||||
COMSIG_ATOM_ENTERED = .proc/on_entered,
|
||||
)
|
||||
AddElement(/datum/element/connect_loc, loc_connections)
|
||||
|
||||
/obj/structure/table/glass/Destroy()
|
||||
QDEL_LIST(debris)
|
||||
. = ..()
|
||||
|
||||
/obj/structure/table/glass/proc/on_entered(datum/source, atom/movable/AM)
|
||||
SIGNAL_HANDLER
|
||||
if(flags_1 & NODECONSTRUCT_1)
|
||||
@@ -429,18 +420,18 @@
|
||||
if(M.has_gravity() && M.mob_size > MOB_SIZE_SMALL && !(M.movement_type & FLYING))
|
||||
table_shatter(M)
|
||||
|
||||
/obj/structure/table/glass/proc/table_shatter(mob/living/L)
|
||||
/obj/structure/table/glass/proc/table_shatter(mob/living/victim)
|
||||
visible_message(span_warning("[src] breaks!"),
|
||||
span_danger("You hear breaking glass."))
|
||||
var/turf/T = get_turf(src)
|
||||
playsound(T, SFX_SHATTER, 50, TRUE)
|
||||
for(var/I in debris)
|
||||
var/atom/movable/AM = I
|
||||
AM.forceMove(T)
|
||||
debris -= AM
|
||||
if(istype(AM, /obj/item/shard))
|
||||
AM.throw_impact(L)
|
||||
L.Paralyze(100)
|
||||
|
||||
playsound(loc, SFX_SHATTER, 50, TRUE)
|
||||
|
||||
new frame(loc)
|
||||
|
||||
var/obj/item/shard/shard = new glass_shard_type(loc)
|
||||
shard.throw_impact(victim)
|
||||
|
||||
victim.Paralyze(100)
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/table/glass/deconstruct(disassembled = TRUE, wrench_disassembly = 0)
|
||||
@@ -451,16 +442,14 @@
|
||||
else
|
||||
var/turf/T = get_turf(src)
|
||||
playsound(T, SFX_SHATTER, 50, TRUE)
|
||||
for(var/X in debris)
|
||||
var/atom/movable/AM = X
|
||||
AM.forceMove(T)
|
||||
debris -= AM
|
||||
|
||||
new frame(loc)
|
||||
new glass_shard_type(loc)
|
||||
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/table/glass/narsie_act()
|
||||
color = NARSIE_WINDOW_COLOUR
|
||||
for(var/obj/item/shard/S in debris)
|
||||
S.color = NARSIE_WINDOW_COLOUR
|
||||
|
||||
/obj/structure/table/glass/plasmaglass
|
||||
name = "plasma glass table"
|
||||
@@ -470,6 +459,7 @@
|
||||
base_icon_state = "plasmaglass_table"
|
||||
custom_materials = list(/datum/material/alloy/plasmaglass = 2000)
|
||||
buildstack = /obj/item/stack/sheet/plasmaglass
|
||||
glass_shard_type = /obj/item/shard/plasma
|
||||
max_integrity = 100
|
||||
|
||||
/*
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
|
||||
/obj/structure/tank_dispenser/Initialize(mapload)
|
||||
. = ..()
|
||||
for(var/i in 1 to oxygentanks)
|
||||
new /obj/item/tank/internals/oxygen(src)
|
||||
for(var/i in 1 to plasmatanks)
|
||||
new /obj/item/tank/internals/plasma(src)
|
||||
update_appearance()
|
||||
|
||||
/obj/structure/tank_dispenser/update_overlays()
|
||||
@@ -91,18 +87,20 @@
|
||||
return
|
||||
switch(action)
|
||||
if("plasma")
|
||||
var/obj/item/tank/internals/plasma/tank = locate() in src
|
||||
if(tank && Adjacent(usr))
|
||||
usr.put_in_hands(tank)
|
||||
plasmatanks--
|
||||
. = TRUE
|
||||
if (plasmatanks == 0)
|
||||
return TRUE
|
||||
|
||||
dispense(/obj/item/tank/internals/plasma, usr)
|
||||
plasmatanks--
|
||||
if("oxygen")
|
||||
var/obj/item/tank/internals/oxygen/tank = locate() in src
|
||||
if(tank && Adjacent(usr))
|
||||
usr.put_in_hands(tank)
|
||||
oxygentanks--
|
||||
. = TRUE
|
||||
if (oxygentanks == 0)
|
||||
return TRUE
|
||||
|
||||
dispense(/obj/item/tank/internals/oxygen, usr)
|
||||
oxygentanks--
|
||||
|
||||
update_appearance()
|
||||
return TRUE
|
||||
|
||||
|
||||
/obj/structure/tank_dispenser/deconstruct(disassembled = TRUE)
|
||||
@@ -113,4 +111,10 @@
|
||||
new /obj/item/stack/sheet/iron (loc, 2)
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/tank_dispenser/proc/dispense(tank_type, mob/receiver)
|
||||
var/existing_tank = locate(tank_type) in src
|
||||
if (isnull(existing_tank))
|
||||
existing_tank = new tank_type
|
||||
receiver.put_in_hands(existing_tank)
|
||||
|
||||
#undef TANK_DISPENSER_CAPACITY
|
||||
|
||||
Reference in New Issue
Block a user