use rust 1.18's new feature to boost the purge performance

This commit is contained in:
Guanqun Lu 2017-06-09 01:26:46 +08:00
parent dabd5b2cc8
commit cd3a1c1a94
2 changed files with 2 additions and 6 deletions

View File

@ -53,7 +53,7 @@ below to build from source.
## Build dependencies
**Parity requires Rust version 1.17.0 to build**
**Parity requires Rust version 1.18.0 to build**
We recommend installing Rust through [rustup](https://www.rustup.rs/). If you don't already have rustup, you can install it like this:

View File

@ -103,11 +103,7 @@ impl MemoryDB {
/// Purge all zero-referenced data from the database.
pub fn purge(&mut self) {
let empties: Vec<_> = self.data.iter()
.filter(|&(_, &(_, rc))| rc == 0)
.map(|(k, _)| k.clone())
.collect();
for empty in empties { self.data.remove(&empty); }
self.data.retain(|_, &mut (_, rc)| rc != 0);
}
/// Return the internal map of hashes to data, clearing the current state.