From ae08be5f3dd79241d716d2f583fd67cebfedd6c9 Mon Sep 17 00:00:00 2001 From: Kyle Spier-Swenson Date: Tue, 9 Jan 2024 21:40:00 -0800 Subject: [PATCH] Make list clear nulls faster (#80869) The old version makes a new list of n null values, and removes it from the given list. for larger lists, this newer 515 version should be faster and lead to less list churn. ![image](https://github.com/tgstation/tgstation/assets/7069733/9c23cc8b-06c4-4a54-99b4-2c44608cf434) --- code/__HELPERS/_lists.dm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index 918428daf77..361bd10f329 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -403,10 +403,8 @@ * Returns TRUE if the list had nulls, FALSE otherwise **/ /proc/list_clear_nulls(list/list_to_clear) - var/start_len = list_to_clear.len - var/list/new_list = new(start_len) - list_to_clear -= new_list - return list_to_clear.len < start_len + return (list_to_clear.RemoveAll(null) > 0) + /** * Removes any empty weakrefs from the list