Merge pull request #2977 from Citadel-Station-13/upstream-merge-31027

[MIRROR] GetAllContents performance increase
This commit is contained in:
LetterJay
2017-09-29 01:41:58 -04:00
committed by GitHub
2 changed files with 7 additions and 23 deletions
+6 -22
View File
@@ -502,28 +502,12 @@ Turf and target are separate in case you want to teleport some distance from a t
var/y=arcsin(x/sqrt(1+x*x))
return y
/atom/proc/GetAllContents(list/ignore_typecache)
var/list/processing_list = list(src)
var/list/assembled = list()
if(ignore_typecache) //If there's a typecache, use it.
while(processing_list.len)
var/atom/A = processing_list[1]
processing_list -= A
if(ignore_typecache[A.type])
continue
processing_list |= (A.contents - assembled)
assembled |= A
else //If there's none, only make this check once for performance.
while(processing_list.len)
var/atom/A = processing_list[1]
processing_list -= A
processing_list |= (A.contents - assembled)
assembled |= A
return assembled
/atom/proc/GetAllContents(list/output=list())
. = output
output += src
for(var/i in 1 to contents.len)
var/atom/thing = contents[i]
thing.GetAllContents(output)
//Step-towards method of determining whether one atom can see another. Similar to viewers()
/proc/can_see(atom/source, atom/target, length=5) // I couldnt be arsed to do actual raycasting :I This is horribly inaccurate.
+1 -1
View File
@@ -444,7 +444,7 @@
/turf/proc/empty(turf_type=/turf/open/space, baseturf_type, list/ignore_typecache, forceop = FALSE)
// Remove all atoms except observers, landmarks, docking ports
var/static/list/ignored_atoms = typecacheof(list(/mob/dead, /obj/effect/landmark, /obj/docking_port, /atom/movable/lighting_object))
var/list/allowed_contents = typecache_filter_list_reverse(GetAllContents(ignore_typecache), ignored_atoms)
var/list/allowed_contents = typecache_filter_list_reverse(GetAllContents(), ignored_atoms | ignore_typecache)
allowed_contents -= src
for(var/i in 1 to allowed_contents.len)
var/thing = allowed_contents[i]