Optimize separate constraint for each stream argument.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -57,9 +57,10 @@ where
|
|||||||
/// Intersection of sets
|
/// Intersection of sets
|
||||||
///
|
///
|
||||||
/// Outputs the set of elements common to both streams. Streams must be sorted.
|
/// Outputs the set of elements common to both streams. Streams must be sorted.
|
||||||
pub fn intersection_sorted_stream2<Item, S>(a: S, b: S) -> impl Stream<Item = Item> + Send
|
pub fn intersection_sorted_stream2<Item, A, B>(a: A, b: B) -> impl Stream<Item = Item> + Send
|
||||||
where
|
where
|
||||||
S: Stream<Item = Item> + Send + Unpin,
|
A: Stream<Item = Item> + Send,
|
||||||
|
B: Stream<Item = Item> + Send + Unpin,
|
||||||
Item: Eq + PartialOrd + Send + Sync,
|
Item: Eq + PartialOrd + Send + Sync,
|
||||||
{
|
{
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
@@ -86,9 +87,10 @@ where
|
|||||||
///
|
///
|
||||||
/// Outputs the set of elements found in `a` which are not found in `b`. Streams
|
/// Outputs the set of elements found in `a` which are not found in `b`. Streams
|
||||||
/// must be sorted.
|
/// must be sorted.
|
||||||
pub fn difference_sorted_stream2<Item, S>(a: S, b: S) -> impl Stream<Item = Item> + Send
|
pub fn difference_sorted_stream2<Item, A, B>(a: A, b: B) -> impl Stream<Item = Item> + Send
|
||||||
where
|
where
|
||||||
S: Stream<Item = Item> + Send + Unpin,
|
A: Stream<Item = Item> + Send,
|
||||||
|
B: Stream<Item = Item> + Send + Unpin,
|
||||||
Item: Eq + PartialOrd + Send + Sync,
|
Item: Eq + PartialOrd + Send + Sync,
|
||||||
{
|
{
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ pub fn get_shared_rooms<'a>(
|
|||||||
) -> impl Stream<Item = &RoomId> + Send + 'a {
|
) -> impl Stream<Item = &RoomId> + Send + 'a {
|
||||||
use tuwunel_core::utils::set;
|
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();
|
let b = self.rooms_joined(user_b).boxed();
|
||||||
|
|
||||||
set::intersection_sorted_stream2(a, b)
|
set::intersection_sorted_stream2(a, b)
|
||||||
|
|||||||
Reference in New Issue
Block a user