From 090e5e0301e5d1dd7979938f573ceff8c08e15ac Mon Sep 17 00:00:00 2001 From: Moritz Hoffmann Date: Fri, 19 Nov 2021 20:12:24 -0500 Subject: [PATCH] exchange: Improve comments Signed-off-by: Moritz Hoffmann --- timely/src/dataflow/channels/mod.rs | 4 ++-- timely/src/dataflow/channels/pushers/exchange.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/timely/src/dataflow/channels/mod.rs b/timely/src/dataflow/channels/mod.rs index 352adfff3..7d174f083 100644 --- a/timely/src/dataflow/channels/mod.rs +++ b/timely/src/dataflow/channels/mod.rs @@ -54,7 +54,7 @@ impl Message { Self::push_at_no_allocation(buffer, time, pusher); - // TODO: Unclear we always want this here. + // Allocate a default buffer to avoid oddly sized or empty buffers if buffer.capacity() != Self::default_length() { *buffer = Vec::with_capacity(Self::default_length()); } @@ -67,7 +67,7 @@ impl Message { #[inline] pub fn push_at_no_allocation>>(buffer: &mut Vec, time: T, pusher: &mut P) { - let data = ::std::mem::replace(buffer, Vec::new()); + let data = ::std::mem::take(buffer); let message = Message::new(time, data, 0, 0); let mut bundle = Some(Bundle::from_typed(message)); diff --git a/timely/src/dataflow/channels/pushers/exchange.rs b/timely/src/dataflow/channels/pushers/exchange.rs index fad8340c6..21c781cff 100644 --- a/timely/src/dataflow/channels/pushers/exchange.rs +++ b/timely/src/dataflow/channels/pushers/exchange.rs @@ -63,6 +63,9 @@ impl>, H: FnMut(&T, &D)->u64> Push::default_length() { let to_reserve = Message::::default_length() - self.buffers[index].capacity(); self.buffers[index].reserve(to_reserve); @@ -85,6 +88,8 @@ impl>, H: FnMut(&T, &D)->u64> Push::default_length() { let to_reserve = Message::::default_length() - self.buffers[index].capacity(); self.buffers[index].reserve(to_reserve);