From c3ed8de7707f1641eb932e07f8bfc1599301fb8c Mon Sep 17 00:00:00 2001 From: Fox-McCloud Date: Fri, 4 Aug 2017 17:15:47 -0400 Subject: [PATCH] faster --- code/__HELPERS/lists.dm | 7 +++++++ code/modules/power/tesla/energy_ball.dm | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/code/__HELPERS/lists.dm b/code/__HELPERS/lists.dm index c89734a0ed3..3556ef2d6f4 100644 --- a/code/__HELPERS/lists.dm +++ b/code/__HELPERS/lists.dm @@ -87,6 +87,13 @@ if(!typecache[A.type]) . += A +/proc/typecache_filter_multi_list_exclusion(list/atoms, list/typecache_include, list/typecache_exclude) + . = list() + for(var/thing in atoms) + var/atom/A = thing + if(typecache_include[A.type] && !typecache_exclude[A.type]) + . += A + //Like typesof() or subtypesof(), but returns a typecache instead of a list /proc/typecacheof(path, ignore_root_path) if(ispath(path)) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index fc3e1cce22b..f2ffbb9b857 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -171,7 +171,7 @@ /obj/machinery/the_singularitygen/tesla)) - for(var/A in typecache_filter_list_reverse(typecache_filter_list(oview(source, zap_range+2), things_to_shock), blacklisted_tesla_types)) + for(var/A in typecache_filter_multi_list_exclusion(oview(source, zap_range+2), things_to_shock, blacklisted_tesla_types)) if(istype(A, /obj/machinery/power/tesla_coil)) var/dist = get_dist(source, A) var/obj/machinery/power/tesla_coil/C = A