From a520506dd6356038c6570245d7809da168e7e9a9 Mon Sep 17 00:00:00 2001 From: Kyle Spier-Swenson Date: Fri, 25 Nov 2016 21:38:52 -0800 Subject: [PATCH] Faster listclearnulls() About twice as fast on lists with 25% nulls in testing http://hastebin.com/amofejukoc.php --- code/__HELPERS/lists.dm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/code/__HELPERS/lists.dm b/code/__HELPERS/lists.dm index 2bc80046a9b..50ce84bf809 100644 --- a/code/__HELPERS/lists.dm +++ b/code/__HELPERS/lists.dm @@ -104,13 +104,8 @@ //Removes any null entries from the list /proc/listclearnulls(list/L) - if(istype(L)) - var/i=1 - for(var/thing in L) - if(thing != null) - ++i - continue - L.Cut(i,i+1) + var/list/N = new(L.len) + L -= N /* * Returns list containing all the entries from first list that are not present in second. @@ -412,4 +407,4 @@ #define UNSETEMPTY(L) if (L && !L.len) L = null -#define LAZYLEN(L) ( L ? L.len : 0 ) \ No newline at end of file +#define LAZYLEN(L) ( L ? L.len : 0 )