Attempts an optimisation for power_change

- Adds an alternate, hopefully faster list iteration method for machines in power_change
- Removes uses of INVOKE_ASYNC for power_change, since it's slower than normal proc calls and does nothing since it doesn't sleep
TODO: Diagnose what the fuck is making power_change so slow anyway.
This commit is contained in:
MarinaGryphon
2021-08-20 16:55:47 -05:00
committed by GitHub
parent 8e442b5472
commit 9d8f34dd8d
+14 -10
View File
@@ -310,7 +310,7 @@ GLOBAL_LIST_EMPTY(teleportlocs)
A.power_light = FALSE
A.power_equip = FALSE
A.power_environ = FALSE
INVOKE_ASYNC(A, .proc/power_change)
A.power_change()
STOP_PROCESSING(SSobj, src)
return ..()
@@ -544,15 +544,19 @@ GLOBAL_LIST_EMPTY(teleportlocs)
// called when power status changes
/area/proc/power_change()
for(var/obj/machinery/M in src) // for each machine in the area
M.power_change() // reverify power status (to update icons etc.)
if(sub_areas)
for(var/i in sub_areas)
var/area/A = i
A.power_light = power_light
A.power_equip = power_equip
A.power_environ = power_environ
INVOKE_ASYNC(A, .proc/power_change)
if(contents.len < GLOB.machines.len) // it would be faster to loop over contents
for(var/obj/machinery/M in src) // for each machine in the area
M.power_change() // reverify power status (to update icons etc.)
else // it would be faster to loop over the machines list
for(var/obj/machinery/M as anything in GLOB.machines) // for each machine
if(get_area(M) != src) // in the area
continue
M.power_change() // reverify power status (to update icons etc.)
for(var/area/A as anything in sub_areas)
A.power_light = power_light
A.power_equip = power_equip
A.power_environ = power_environ
A.power_change()
update_appearance()
/area/proc/usage(chan)