Itertools are no longer reexported from util, optimized triedb iter

This commit is contained in:
debris
2017-08-17 16:05:26 +02:00
parent fefc756870
commit 4cb610d9ae
18 changed files with 34 additions and 15 deletions

View File

@@ -21,7 +21,6 @@ use std::collections::HashMap;
use std::sync::Arc;
use parking_lot::RwLock;
use heapsize::HeapSizeOf;
use itertools::Itertools;
use rlp::*;
use hashdb::*;
use memorydb::*;
@@ -432,7 +431,9 @@ impl JournalDB for EarlyMergeDB {
// - we write the key into our journal for this block;
r.begin_list(inserts.len());
inserts.iter().foreach(|&(k, _)| {r.append(&k);});
for &(k, _) in &inserts {
r.append(&k);
}
r.append_list(&removes);
Self::insert_keys(&inserts, &*self.backing, self.column, &mut refs, batch, trace);

View File

@@ -106,7 +106,6 @@ extern crate rlp;
extern crate regex;
extern crate lru_cache;
extern crate heapsize;
extern crate itertools;
extern crate ethcore_logger;
#[macro_use]
@@ -153,7 +152,6 @@ pub use bigint::hash;
pub use ansi_term::{Colour, Style};
pub use heapsize::HeapSizeOf;
pub use itertools::Itertools;
pub use parking_lot::{Condvar, Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
/// 160-bit integer representing account address

View File

@@ -15,7 +15,6 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::fmt;
use itertools::Itertools;
use hashdb::*;
use nibbleslice::*;
use rlp::*;
@@ -293,7 +292,18 @@ impl<'a> TrieDBIterator<'a> {
/// The present key.
fn key(&self) -> Bytes {
// collapse the key_nibbles down to bytes.
self.key_nibbles.iter().step(2).zip(self.key_nibbles.iter().skip(1).step(2)).map(|(h, l)| h * 16 + l).collect()
unsafe {
let size = self.key_nibbles.len() / 2;
let mut ptr = self.key_nibbles.as_ptr();
let mut result = Bytes::with_capacity(size);
for _ in 0..size {
result.push(*ptr * 16 + *ptr.offset(1));
ptr = ptr.offset(2);
}
result
}
}
}