Multi-ZAS Optimization

A simple optimization to can_safely_remove_from_zone() both with and without multi-zas.
Instead of allocating a new list every time we call get_zone_neighbours() (which gets called several times in a loop) we have a pre-built list we don't need to Copy().
Same story for the list to iterate over in can_safely_remove_from_zone()
There should be no semantic change whatsoever from this; it is purely a performance optimization.
This commit is contained in:
Leshana
2017-04-17 19:50:02 -04:00
parent 75ae42ca81
commit f8a538eff9
3 changed files with 10 additions and 14 deletions

View File

@@ -58,10 +58,13 @@
var/check_dirs = get_zone_neighbours(src)
var/unconnected_dirs = check_dirs
var/to_check = list(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST)
#ifdef MULTIZAS
to_check += list(NORTHUP, EASTUP, WESTUP, SOUTHUP, NORTHDOWN, EASTDOWN, WESTDOWN, SOUTHDOWN)
var/to_check = cornerdirsz
#else
var/to_check = cornerdirs
#endif
for(var/dir in to_check)
//for each pair of "adjacent" cardinals (e.g. NORTH and WEST, but not NORTH and SOUTH)
if((dir & check_dirs) == dir)
@@ -77,9 +80,10 @@
/turf/simulated/proc/get_zone_neighbours(turf/simulated/T)
. = 0
if(istype(T) && T.zone)
var/to_check = cardinal.Copy()
#ifdef MULTIZAS
to_check += list(UP, DOWN)
var/to_check = cardinalz
#else
var/to_check = cardinal
#endif
for(var/dir in to_check)
var/turf/simulated/other = get_step(T, dir)