From fc0f04defaf40668098595d0db4312fb7f609bc4 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 20 Oct 2025 20:44:45 +0000 Subject: [PATCH] Optimize watcher range collection on notify. Signed-off-by: Jason Volk --- src/database/map/watch.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/database/map/watch.rs b/src/database/map/watch.rs index 19776872..7bb29c5c 100644 --- a/src/database/map/watch.rs +++ b/src/database/map/watch.rs @@ -8,11 +8,12 @@ use std::{ use futures::pin_mut; use serde::Serialize; use tokio::sync::watch::{Sender, channel}; -use tuwunel_core::implement; +use tuwunel_core::{implement, smallvec::SmallVec}; use crate::keyval::{KeyBuf, serialize_key}; type Watchers = Mutex>>; +type KeyVec = SmallVec<[KeyBuf; 1]>; #[derive(Default)] pub(super) struct Watch { @@ -71,7 +72,7 @@ where .take_while(|(k, _)| key.as_ref().starts_with(k)) .filter_map(|(k, tx)| tx.send(()).is_err().then_some(k)) .cloned() - .collect::>() + .collect::() .into_iter() .for_each(|k| { watchers.remove(&k);