From 627f72595869c7feaf40b660c0ab57dbce5532aa Mon Sep 17 00:00:00 2001 From: deathride58 Date: Sat, 30 Mar 2019 23:44:56 -0400 Subject: [PATCH] Optimizes get_hearers_in_view by caching the results of view() --- code/__HELPERS/game.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index ad29125d95..899ef16306 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -221,9 +221,10 @@ else // A variation of get_hear inlined here to take advantage of the compiler's fastpath for obj/mob in view var/lum = T.luminosity T.luminosity = 6 // This is the maximum luminosity - for(var/mob/M in view(R, T)) + var/list/cachedview = view(R, T) + for(var/mob/M in cachedview) processing_list += M - for(var/obj/O in view(R, T)) + for(var/obj/O in cachedview) processing_list += O T.luminosity = lum