From 7589ff92854959b9cda5852deb046a9186650e66 Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Sat, 10 Jun 2017 17:02:12 -0500 Subject: [PATCH] LAZYSET() Macro --- code/__HELPERS/_lists.dm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index 9847ab32e7..b575da3803 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -451,13 +451,12 @@ //Picks from the list, with some safeties, and returns the "default" arg if it fails #define DEFAULTPICK(L, default) ((istype(L, /list) && L:len) ? pick(L) : default) - #define LAZYINITLIST(L) if (!L) L = list() - #define UNSETEMPTY(L) if (L && !L.len) L = null #define LAZYREMOVE(L, I) if(L) { L -= I; if(!L.len) { L = null; } } #define LAZYADD(L, I) if(!L) { L = list(); } L += I; #define LAZYACCESS(L, I) (L ? (isnum(I) ? (I > 0 && I <= L.len ? L[I] : null) : L[I]) : null) +#define LAZYSET(L, K, V) if(!L) { L = list(); } L[K] = V; #define LAZYLEN(L) length(L) #define LAZYCLEARLIST(L) if(L) L.Cut() #define SANITIZE_LIST(L) ( islist(L) ? L : list() )