aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/tree.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm/tree.rs')
-rw-r--r--src/swarm/tree.rs8
1 files changed, 4 insertions, 4 deletions
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<u64>,
round_trips: Option<Vec<u8>>,
@@ -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)