From 8b85f648ca6e02f77fd9370e54904e860f4b006f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 13 Nov 2017 17:09:30 +0100 Subject: [PATCH] HashMap::retain --- rpc/src/v1/helpers/nonce.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rpc/src/v1/helpers/nonce.rs b/rpc/src/v1/helpers/nonce.rs index 2b4df49ae..30ad15211 100644 --- a/rpc/src/v1/helpers/nonce.rs +++ b/rpc/src/v1/helpers/nonce.rs @@ -57,10 +57,7 @@ impl Reservations { /// The reserved nonce cannot be smaller than the minimal nonce. pub fn reserve(&mut self, sender: Address, minimal: U256) -> Reserved { if self.nonces.len() + 1 > Self::CLEAN_AT { - let to_remove = self.nonces.iter().filter(|&(_, v)| v.is_empty()).map(|(k, _)| *k).collect::>(); - for address in to_remove { - self.nonces.remove(&address); - } + self.nonces.retain(|_, v| !v.is_empty()); } let pool = &self.pool;