From 547031aa0e48185a05d7aa7db07544b6190d0bd2 Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Wed, 28 Jun 2017 00:23:53 +0800 Subject: [PATCH] sync: make it more idiomatic rust (#5938) --- sync/src/snapshot.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sync/src/snapshot.rs b/sync/src/snapshot.rs index ffdaecd79..cecfbe425 100644 --- a/sync/src/snapshot.rs +++ b/sync/src/snapshot.rs @@ -92,14 +92,10 @@ impl Snapshot { /// Find a chunk to download pub fn needed_chunk(&mut self) -> Option { // check state chunks first - let mut chunk = self.pending_state_chunks.iter() + let chunk = self.pending_state_chunks.iter() + .chain(self.pending_block_chunks.iter()) .find(|&h| !self.downloading_chunks.contains(h) && !self.completed_chunks.contains(h)) .cloned(); - if chunk.is_none() { - chunk = self.pending_block_chunks.iter() - .find(|&h| !self.downloading_chunks.contains(h) && !self.completed_chunks.contains(h)) - .cloned(); - } if let Some(hash) = chunk { self.downloading_chunks.insert(hash.clone());