mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 07:08:00 +01:00
[MIRROR] Load circuit components from USB ports on demand, saving 0.5s of init time (0.7s on prod) [MDB IGNORE] (#16041)
* Load circuit components from USB ports on demand, saving 0.5s of init time (0.7s on prod) (#69664) We create 2,383 circuit components (on whatever map I was looking at on Sybil at the time, don't know) from USB ports every round, quite pricey. This makes them initialize once when a USB is first plugged in. * Load circuit components from USB ports on demand, saving 0.5s of init time (0.7s on prod) Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
|
||||
circuit_components = list()
|
||||
|
||||
set_circuit_components(circuit_component_types)
|
||||
src.circuit_component_types = circuit_component_types
|
||||
|
||||
/datum/component/usb_port/proc/set_circuit_components(list/components)
|
||||
var/should_register = FALSE
|
||||
@@ -136,6 +136,9 @@
|
||||
/datum/component/usb_port/proc/on_atom_usb_cable_try_attach(datum/source, obj/item/usb_cable/connecting_cable, mob/user)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if (!length(circuit_components))
|
||||
set_circuit_components(circuit_component_types)
|
||||
|
||||
var/atom/atom_parent = parent
|
||||
|
||||
if (!isnull(attached_circuit))
|
||||
@@ -156,7 +159,7 @@
|
||||
if (connecting_cable.attached_circuit.locked)
|
||||
connecting_cable.balloon_alert(user, "shell is locked!")
|
||||
return COMSIG_CANCEL_USB_CABLE_ATTACK
|
||||
|
||||
|
||||
usb_cable_ref = WEAKREF(connecting_cable)
|
||||
attached_circuit = connecting_cable.attached_circuit
|
||||
|
||||
|
||||
Reference in New Issue
Block a user