From 6cbfa468055a4cdb43c34e4964ca65f58c5bce7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 14 Apr 2022 17:29:56 +0200 Subject: [PATCH] udp: improve code in PendingScrapeResponseSlab.clean --- aquatic_udp/src/workers/socket.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/aquatic_udp/src/workers/socket.rs b/aquatic_udp/src/workers/socket.rs index a571e6c..b0a9b7d 100644 --- a/aquatic_udp/src/workers/socket.rs +++ b/aquatic_udp/src/workers/socket.rs @@ -110,18 +110,19 @@ impl PendingScrapeResponseSlab { let now = Instant::now(); self.0.retain(|k, v| { - let keep = v.valid_until.0 > now; - - if !keep { + if v.valid_until.0 > now { + true + } else { ::log::warn!( - "Removing PendingScrapeResponseSlab entry while cleaning. {:?}: {:?}", + "Unconsumed PendingScrapeResponseSlab entry. {:?}: {:?}", k, v ); - } - keep + false + } }); + self.0.shrink_to_fit(); } }