From 1bd91f67979bac25ab1af8a388ad1e3f018dac62 Mon Sep 17 00:00:00 2001 From: Tpt Date: Fri, 29 Nov 2019 09:00:38 +0100 Subject: [PATCH] Simplifies slightly the iteration code --- lib/src/store/rocksdb.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/src/store/rocksdb.rs b/lib/src/store/rocksdb.rs index fa4765f5..7100fe52 100644 --- a/lib/src/store/rocksdb.rs +++ b/lib/src/store/rocksdb.rs @@ -640,16 +640,14 @@ impl<'a, F: Fn(&[u8]) -> Result> Iterator for DecodingIndexIterator type Item = Result; fn next(&mut self) -> Option> { - if self.iter.valid() { - let result = self.iter.key().and_then(|key| { - if key.starts_with(&self.prefix) { - Some((self.decode)(key)) - } else { - None - } - }); - self.iter.next(); - result + if let Some(key) = self.iter.key() { + if key.starts_with(&self.prefix) { + let result = (self.decode)(key); + self.iter.next(); + Some(result) + } else { + None + } } else { None }