From 55653fa1eec0503fb2d69dbface69456fa73c323 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 31 Oct 2017 16:11:32 -0400 Subject: [PATCH] Replace most islist calls in components with length() (#32158) islist was used to check if a thing was A. A list of things B. 1 thing length was profiled to be faster --- code/datums/components/_component.dm | 12 ++++++------ code/datums/datum.dm | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index 4e187a6a08..98aabd528e 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -56,7 +56,7 @@ var/test = dc[I] if(test) //already another component of this type here var/list/components_of_type - if(!islist(test)) + if(!length(test)) components_of_type = list(test) dc[I] = components_of_type else @@ -94,7 +94,7 @@ var/our_type = type for(var/I in _GetInverseTypeList(our_type)) var/list/components_of_type = dc[I] - if(islist(components_of_type)) // + if(length(components_of_type)) // var/list/subtracted = components_of_type - src if(subtracted.len == 1) //only 1 guy left dc[I] = subtracted[1] //make him special @@ -146,7 +146,7 @@ var/list/arguments = args.Copy() arguments.Cut(1, 2) var/target = comps[/datum/component] - if(!islist(target)) + if(!length(target)) var/datum/component/C = target if(!C.enabled) return FALSE @@ -182,7 +182,7 @@ if(!dc) return null . = dc[c_type] - if(islist(.)) + if(length(.)) return .[1] /datum/proc/GetExactComponent(c_type) @@ -191,7 +191,7 @@ return null var/datum/component/C = dc[c_type] if(C) - if(islist(C)) + if(length(C)) C = C[1] if(C.type == c_type) return C @@ -202,7 +202,7 @@ if(!dc) return null . = dc[c_type] - if(!islist(.)) + if(!length(.)) return list(.) /datum/proc/AddComponent(new_type, ...) diff --git a/code/datums/datum.dm b/code/datums/datum.dm index f7b15035d1..00dd796f47 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -24,7 +24,7 @@ var/list/dc = datum_components if(dc) var/all_components = dc[/datum/component] - if(islist(all_components)) + if(length(all_components)) for(var/I in all_components) var/datum/component/C = I C._RemoveFromParent()