mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 06:00:16 +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:
@@ -456,23 +456,16 @@
|
||||
|
||||
/datum/techweb/specialized/autounlocking
|
||||
var/design_autounlock_buildtypes = NONE
|
||||
var/design_autounlock_categories = list(RND_CATEGORY_INITIAL) //if a design has a buildtype that matches the abovea and either has a category in this or this is null, unlock it.
|
||||
var/node_autounlock_ids = list() //autounlock nodes of this type.
|
||||
|
||||
/datum/techweb/specialized/autounlocking/New()
|
||||
..()
|
||||
autounlock()
|
||||
|
||||
/datum/techweb/specialized/autounlocking/proc/autounlock()
|
||||
for(var/id in node_autounlock_ids)
|
||||
research_node_id(id, TRUE, FALSE, FALSE)
|
||||
for(var/id in SSresearch.techweb_designs)
|
||||
var/datum/design/D = SSresearch.techweb_design_by_id(id)
|
||||
if(D.build_type & design_autounlock_buildtypes)
|
||||
for(var/i in D.category)
|
||||
if(i in design_autounlock_categories)
|
||||
add_design_by_id(D.id)
|
||||
break
|
||||
var/datum/design/design = SSresearch.techweb_designs[id]
|
||||
if((design.build_type & design_autounlock_buildtypes) && (RND_CATEGORY_INITIAL in design.category))
|
||||
add_design_by_id(id)
|
||||
|
||||
/datum/techweb/specialized/autounlocking/autolathe
|
||||
design_autounlock_buildtypes = AUTOLATHE
|
||||
|
||||
Reference in New Issue
Block a user