From 71d9d8e3a6b9192e4feda9e705a6d94985627cbd Mon Sep 17 00:00:00 2001 From: Maple Nebel Date: Mon, 11 May 2026 15:02:56 +0200 Subject: [PATCH] add slight optimization --- rnex-core/src/nex/matchmake.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/rnex-core/src/nex/matchmake.rs b/rnex-core/src/nex/matchmake.rs index 52b5ad1..46ee0f8 100644 --- a/rnex-core/src/nex/matchmake.rs +++ b/rnex-core/src/nex/matchmake.rs @@ -128,7 +128,7 @@ fn check_bounds_str(compare: T, str: &str) -> Option>( - players: &[T], + players: impl Iterator, notification_event: &NotificationEvent, ) { for player in players { @@ -142,16 +142,13 @@ pub async fn broadcast_notification>( impl ExtendedMatchmakeSession { #[inline(always)] - pub fn get_active_players(&self) -> Vec> { - self.connected_players - .iter() - .filter_map(|u| u.upgrade()) - .collect() + pub fn get_active_players(&self) -> impl Iterator> { + self.connected_players.iter().filter_map(|u| u.upgrade()) } #[inline(always)] pub async fn broadcast_notification(&self, notification_event: &NotificationEvent) { - broadcast_notification(&self.get_active_players(), notification_event).await; + broadcast_notification(self.get_active_players(), notification_event).await; } pub async fn from_matchmake_session( @@ -314,7 +311,6 @@ impl ExtendedMatchmakeSession { #[inline] pub fn is_reachable(&self) -> bool { self.get_active_players() - .iter() .any(|v| v.pid == self.session.gathering.host_pid) && (if self.session.gathering.flags & PERSISTENT_GATHERING != 0 { if self.has_active_players() {