From: Ian Jackson Date: Sun, 1 May 2022 01:37:33 +0000 (+0100) Subject: Optimise into_unprepared slightly X-Git-Tag: otter-1.1.0~382 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=4c1235ac974a59f6b719335fb875c30ee7f1aa9e;p=otter.git Optimise into_unprepared slightly Prompted by seeing this optimisation at what ought to be a call site of this method. Signed-off-by: Ian Jackson --- diff --git a/src/updates.rs b/src/updates.rs index 216ca07c..68821f5c 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -1013,10 +1013,14 @@ impl PreparedUpdate { impl Vec<(PieceId, PieceUpdateOps)> { fn into_unprepared(self, by_client: IsResponseToClientOp) -> UnpreparedUpdates { - vec![Box::new( - move |buf: &mut PrepareUpdatesBuffer| { - buf.piece_updates(self, &by_client) - })] + if self.len() != 0 { + vec![Box::new( + move |buf: &mut PrepareUpdatesBuffer| { + buf.piece_updates(self, &by_client) + })] + } else { + default() + } } }