From afab80f356227fc721d110700c9be26f5736fc5b Mon Sep 17 00:00:00 2001 From: Sun-Soaked <45698967+Sun-Soaked@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:56:45 +0300 Subject: [PATCH] [MIRROR] Ports a super small TG signal optimization --- code/datums/components/_component.dm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index 1d16391a18e1..d76504787b04 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -321,10 +321,12 @@ // all the objects that are receiving the signal get the signal this final time. // AKA: No you can't cancel the signal reception of another object by doing an unregister in the same signal. var/list/queued_calls = list() - for(var/datum/listening_datum as anything in target) - queued_calls[listening_datum] = listening_datum.signal_procs[src][sigtype] - for(var/datum/listening_datum as anything in queued_calls) - . |= call(listening_datum, queued_calls[listening_datum])(arglist(arguments)) + // This should be faster than doing `var/datum/listening_datum as anything in target` as it does not implicitly copy the list + for(var/i in 1 to length(target)) + var/datum/listening_datum = target[i] + queued_calls.Add(listening_datum, listening_datum.signal_procs[src][sigtype]) + for(var/i in 1 to length(queued_calls) step 2) + . |= call(queued_calls[i], queued_calls[i + 1])(arglist(arguments)) // The type arg is casted so initial works, you shouldn't be passing a real instance into this /**