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

@@ -19,7 +19,6 @@ rust-crypto = "0.2.34"
elastic-array = "0.9"
rlp = { path = "rlp" }
heapsize = "0.4"
itertools = "0.5"
sha3 = { path = "sha3" }
clippy = { version = "0.0.103", optional = true}
ethcore-devtools = { path = "../devtools" }

View File

@@ -45,14 +45,14 @@ fn random_bytes(min_count: usize, diff_count: usize, seed: &mut H256) -> Vec<u8>
assert!(min_count + diff_count <= 32);
*seed = seed.sha3();
let r = min_count + (seed[31] as usize % (diff_count + 1));
seed[0..r].into_vec()
seed[0..r].to_vec()
}
fn random_value(seed: &mut H256) -> Bytes {
*seed = seed.sha3();
match seed[0] % 2 {
1 => vec![seed[31];1],
_ => seed.into_vec(),
_ => seed.to_vec(),
}
}

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
}
}
}