Skip to content

Commit

Permalink
Ports a super small TG signal optimization (#3053)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
Extremely tiny [port (tg pr
#83244)](tgstation/tgstation#83244) that
allegedly has positive performance implications for signals
<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## 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)

<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

## Changelog

:cl: [Watermelon914](https://github.com/Watermelon914)
code: ports little itty bitty sendsignal optimization from tg
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
Sun-Soaked authored Jun 2, 2024
1 parent d9fd6fe commit e188a2f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions code/datums/components/_component.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand Down

0 comments on commit e188a2f

Please sign in to comment.