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:
+14
-10
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user