mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 05:30:05 +01:00
Makes is_type_in_list() much faster (thanks remie)
This commit is contained in:
@@ -53,10 +53,16 @@
|
||||
|
||||
//Checks for specific types in a list
|
||||
/proc/is_type_in_list(atom/A, list/L)
|
||||
if (!L.len)
|
||||
return 0
|
||||
if (!isnum(L[L[1]]))
|
||||
generate_type_list_cache(L)
|
||||
return L[A.type]
|
||||
|
||||
/proc/generate_type_list_cache(L)
|
||||
for(var/type in L)
|
||||
if(istype(A, type))
|
||||
return 1
|
||||
return 0
|
||||
for(var/T in typesof(type))
|
||||
L[T] = 1
|
||||
|
||||
//Empties the list by setting the length to 0. Hopefully the elements get garbage collected
|
||||
/proc/clearlist(list/list)
|
||||
|
||||
Reference in New Issue
Block a user