From c51bb8a4d8ece9f48d40482b0af8e4be9f771432 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 6 Nov 2026 04:32:07 +0100 Subject: reach sets bounded --- src/swarm/tree.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/swarm/tree.rs') diff --git a/src/swarm/tree.rs b/src/swarm/tree.rs index 81004e8..3ed8a9b 100644 --- a/src/swarm/tree.rs +++ b/src/swarm/tree.rs @@ -202,8 +202,8 @@ pub(crate) fn whole( ) } -/// Whom a member reaches, by pair key, and its round trip to each (`rtt::bucket`), as -/// it said. +/// Whom a member reaches, by pair key, sorted (`reach::said`), and its round trip to +/// each (`rtt::bucket`), as it said. struct Said { keys: Vec, round_trips: Option>, @@ -219,7 +219,7 @@ impl Known<'_> { fn reached(&self, by: &str, member: &str) -> bool { self.0 .get(by) - .is_none_or(|said| said.keys.contains(&topology::pair_key(member))) + .is_none_or(|said| said.keys.binary_search(&topology::pair_key(member)).is_ok()) } /// `by`'s round trip to `member`, as a bucket; `rtt::UNKNOWN_BUCKET` if not said. @@ -228,7 +228,7 @@ impl Known<'_> { self.0 .get(by) .and_then(|said| { - let index = said.keys.iter().position(|said| *said == key)?; + let index = said.keys.binary_search(&key).ok()?; said.round_trips.as_ref()?.get(index).copied() }) .unwrap_or(rtt::UNKNOWN_BUCKET) -- cgit v1.3.1