Merge pull request #3966 from Citadel-Station-13/upstream-merge-32650
[MIRROR] Speeds up saycode by almost doubling get_hearers_in_view() performance
This commit is contained in:
+18
-7
@@ -214,17 +214,28 @@
|
||||
/proc/get_hearers_in_view(R, atom/source)
|
||||
// Returns a list of hearers in view(R) from source (ignoring luminosity). Used in saycode.
|
||||
var/turf/T = get_turf(source)
|
||||
var/list/hear = list()
|
||||
. = list()
|
||||
|
||||
if(!T)
|
||||
return hear
|
||||
return
|
||||
|
||||
var/list/range = get_hear(R, T)
|
||||
for(var/atom/movable/A in range)
|
||||
hear |= recursive_hear_check(A)
|
||||
|
||||
return hear
|
||||
var/list/processing_list = list()
|
||||
if (R == 0) // if the range is zero, we know exactly where to look for, we can skip view
|
||||
processing_list += T.contents // We can shave off one iteration by assuming turfs cannot hear
|
||||
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
|
||||
processing_list = viewers(R, T)
|
||||
for(var/obj/O in view(R, T))
|
||||
processing_list += O
|
||||
T.luminosity = lum
|
||||
|
||||
while(processing_list.len) // recursive_hear_check inlined here
|
||||
var/atom/A = processing_list[1]
|
||||
if(A.flags_1 & HEAR_1)
|
||||
. += A
|
||||
processing_list.Cut(1, 2)
|
||||
processing_list += A.contents
|
||||
|
||||
/proc/get_mobs_in_radio_ranges(list/obj/item/device/radio/radios)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user