From dd9082f90357ba6220fdc910d4e11791d6cb8b4f Mon Sep 17 00:00:00 2001 From: HarpyEagle Date: Fri, 20 May 2016 15:17:47 -0400 Subject: [PATCH] get_turf optimization Checks isturf() and then locs instead of looping --- code/_helpers/unsorted.dm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/code/_helpers/unsorted.dm b/code/_helpers/unsorted.dm index b770693a69a..e3c1eb15a05 100644 --- a/code/_helpers/unsorted.dm +++ b/code/_helpers/unsorted.dm @@ -1039,10 +1039,9 @@ proc/get_mob_with_client_list() //gets the turf the atom is located in (or itself, if it is a turf). //returns null if the atom is not in a turf. -/proc/get_turf(atom/A) - if(!istype(A)) return - for(A, A && !isturf(A), A=A.loc); - return A +/proc/get_turf(atom/movable/A) + if(isturf(A)) return A + if(A.locs.len) return A.locs[1] /proc/get(atom/loc, type) while(loc)