From e84d6666c0906cd492ab58f65db0ec9ced5f9fac Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 27 Nov 2025 11:13:27 +0000 Subject: [PATCH] Optimize separate constraint for each stream argument. Signed-off-by: Jason Volk --- src/core/utils/set.rs | 10 ++++++---- src/service/rooms/state_cache/mod.rs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/utils/set.rs b/src/core/utils/set.rs index 673ea858..d3485bb8 100644 --- a/src/core/utils/set.rs +++ b/src/core/utils/set.rs @@ -57,9 +57,10 @@ where /// Intersection of sets /// /// Outputs the set of elements common to both streams. Streams must be sorted. -pub fn intersection_sorted_stream2(a: S, b: S) -> impl Stream + Send +pub fn intersection_sorted_stream2(a: A, b: B) -> impl Stream + Send where - S: Stream + Send + Unpin, + A: Stream + Send, + B: Stream + Send + Unpin, Item: Eq + PartialOrd + Send + Sync, { use tokio::sync::Mutex; @@ -86,9 +87,10 @@ where /// /// Outputs the set of elements found in `a` which are not found in `b`. Streams /// must be sorted. -pub fn difference_sorted_stream2(a: S, b: S) -> impl Stream + Send +pub fn difference_sorted_stream2(a: A, b: B) -> impl Stream + Send where - S: Stream + Send + Unpin, + A: Stream + Send, + B: Stream + Send + Unpin, Item: Eq + PartialOrd + Send + Sync, { use tokio::sync::Mutex; diff --git a/src/service/rooms/state_cache/mod.rs b/src/service/rooms/state_cache/mod.rs index b109452e..03216c56 100644 --- a/src/service/rooms/state_cache/mod.rs +++ b/src/service/rooms/state_cache/mod.rs @@ -212,7 +212,7 @@ pub fn get_shared_rooms<'a>( ) -> impl Stream + Send + 'a { use tuwunel_core::utils::set; - let a = self.rooms_joined(user_a).boxed(); + let a = self.rooms_joined(user_a); let b = self.rooms_joined(user_b).boxed(); set::intersection_sorted_stream2(a, b)