Pre-sort PDA messengers by name/job instead of sorting every time we list them (#92613)

## About The Pull Request

this gets rid of the `get_messengers_sorted_by_name` and
`get_messengers_sorted_by_job` procs, instead replacing them with two
new global lists: `GLOB.pda_messengers_by_name` and
`GLOB.pda_messengers_by_job`

those two lists are updated in the `add_messenger` proc, which uses the
binary insert macros to insert it into the properly sorted place.

why? bc sorts suck for performance and all inserts/removals to this list
go thru a single proc anyways, so we can just ensure it's sorted like
this once, instead of re-sorting each time.

thanks to @LemonInTheDark for helping me with this

<details>
<summary><h3>Testing Proof</h3></summary>

<img width="1708" height="1349" alt="2025-08-16 (1755391989) ~
dreamseeker"
src="https://github.com/user-attachments/assets/1e2dc99a-1863-4a35-8032-8ae64706fdaa"
/>

<img width="1708" height="1349" alt="2025-08-16 (1755392002) ~
dreamseeker"
src="https://github.com/user-attachments/assets/4d9b3bd0-7f3a-410b-a073-1bf2bd69690b"
/>

</details>

## Why It's Good For The Game

because doing a sort repeatedly whenever someone has their PDA messenger
open is stupid and sucks

## Changelog

no player-facing changes
This commit is contained in:
Lucy
2025-08-17 18:15:18 -04:00
committed by GitHub
parent c80361d5f3
commit 5d8bddfcf4
5 changed files with 21 additions and 23 deletions
+2 -4
View File
@@ -29,8 +29,7 @@ ADMIN_VERB(message_pda, R_ADMIN, "PDA Message", "Send a message to a user's PDA.
/datum/admin_pda_panel/ui_static_data(mob/user)
var/list/data = list()
var/list/available_messengers = list()
for(var/messenger_ref in get_messengers_sorted_by_name())
var/datum/computer_file/program/messenger/messenger = GLOB.pda_messengers[messenger_ref]
for(var/datum/computer_file/program/messenger/messenger as anything in GLOB.pda_messengers_by_name)
available_messengers[REF(messenger)] = list(
ref = REF(messenger),
username = get_messenger_name(messenger),
@@ -55,8 +54,7 @@ ADMIN_VERB(message_pda, R_ADMIN, "PDA Message", "Send a message to a user's PDA.
if(!spam && (ref in GLOB.pda_messengers))
targets += GLOB.pda_messengers[ref]
else
for(var/messenger_ref in get_messengers_sorted_by_name())
var/datum/computer_file/program/messenger/messenger = GLOB.pda_messengers[messenger_ref]
for(var/datum/computer_file/program/messenger/messenger as anything in GLOB.pda_messengers_by_name)
if(messenger.invisible && !params["include_invisible"])
continue
targets += messenger