From e188a2f3d601d05bc630f2c00ed6735c52dab924 Mon Sep 17 00:00:00 2001 From: Sun-Soaked <45698967+Sun-Soaked@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:16:34 -0400 Subject: [PATCH] Ports a super small TG signal optimization (#3053) ## About The Pull Request Extremely tiny [port (tg pr #83244)](https://github.com/tgstation/tgstation/pull/83244) that allegedly has positive performance implications for signals ## Why It's Good For The Game ![image](https://github.com/shiptest-ss13/Shiptest/assets/45698967/1389fd50-5d25-4a88-9f44-a706cfd3ee68) ![image](https://github.com/shiptest-ss13/Shiptest/assets/45698967/660c44c5-4f40-4d6c-9f7f-2d21cbaa12ca) ## Changelog :cl: [Watermelon914](https://github.com/Watermelon914) code: ports little itty bitty sendsignal optimization from tg /:cl: --- 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 /**