From 4f9dba3874ab0da960da14cbfdfccd46a8d03644 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 18 Nov 2021 12:47:27 +0000 Subject: [PATCH] [MIRROR] Micro optimizations: Now much less exhaustive [MDB IGNORE] (#9541) * Micro optimizations: Now much less exhaustive (#62844) * Micro optimizations: Now much less exhaustive Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com> --- code/__HELPERS/_lists.dm | 15 +++++++-------- code/__HELPERS/game.dm | 9 ++++----- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index 13aac6f6f96..e36e510d42d 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -169,8 +169,7 @@ /proc/typecache_filter_list(list/atoms, list/typecache) RETURN_TYPE(/list) . = list() - for(var/thing in atoms) - var/atom/atom_checked = thing + for(var/atom/atom_checked as anything in atoms) if (typecache[atom_checked.type]) . += atom_checked @@ -178,16 +177,16 @@ /proc/typecache_filter_list_reverse(list/atoms, list/typecache) RETURN_TYPE(/list) . = list() - for(var/atom/atom as anything in atoms) - if(!typecache[atom.type]) - . += atom + for(var/atom/atom_checked as anything in atoms) + if(!typecache[atom_checked.type]) + . += atom_checked ///similar to typecache_filter_list and typecache_filter_list_reverse but it supports an inclusion list and and exclusion list /proc/typecache_filter_multi_list_exclusion(list/atoms, list/typecache_include, list/typecache_exclude) . = list() - for(var/atom/atom as anything in atoms) - if(typecache_include[atom.type] && !typecache_exclude[atom.type]) - . += atom + for(var/atom/atom_checked as anything in atoms) + if(typecache_include[atom_checked.type] && !typecache_exclude[atom_checked.type]) + . += atom_checked ///Like typesof() or subtypesof(), but returns a typecache instead of a list /proc/typecacheof(path, ignore_root_path, only_root_path = FALSE) diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index 7f564757b5c..5d1da6d02f7 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -352,10 +352,9 @@ ///wrapper for flick_overlay(), flicks to everyone who can see the target atom /proc/flick_overlay_view(image/image_to_show, atom/target, duration) var/list/viewing = list() - for(var/viewer in viewers(target)) - var/mob/viewer_mob = viewer - if(viewer_mob.client) - viewing += viewer_mob.client + for(var/mob/viewer as anything in viewers(target)) + if(viewer.client) + viewing += viewer.client flick_overlay(image_to_show, viewing, duration) ///Get active players who are playing in the round @@ -584,7 +583,7 @@ /proc/find_obstruction_free_location(range, atom/center, area/specific_area) var/list/possible_loc = list() - for(var/turf/found_turf in RANGE_TURFS(range, center)) + for(var/turf/found_turf as anything in RANGE_TURFS(range, center)) // We check if both the turf is a floor, and that it's actually in the area. // We also want a location that's clear of any obstructions. if (specific_area && !istype(get_area(found_turf), specific_area))