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

3
Cargo.lock generated
View File

@ -773,7 +773,6 @@ dependencies = [
"ethcore-devtools 1.8.0", "ethcore-devtools 1.8.0",
"ethcore-logger 1.8.0", "ethcore-logger 1.8.0",
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1860,6 +1859,7 @@ dependencies = [
"fetch 0.1.0", "fetch 0.1.0",
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
"jsonrpc-http-server 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", "jsonrpc-http-server 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
"linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1971,6 +1971,7 @@ dependencies = [
"fetch 0.1.0", "fetch 0.1.0",
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", "jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
"jsonrpc-http-server 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", "jsonrpc-http-server 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
"jsonrpc-ipc-server 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)", "jsonrpc-ipc-server 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",

View File

@ -27,6 +27,7 @@ time = "0.1.35"
unicase = "1.3" unicase = "1.3"
url = "1.0" url = "1.0"
zip = { version = "0.1", default-features = false } zip = { version = "0.1", default-features = false }
itertools = "0.5"
jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.7" } jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.7" }
jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.7" } jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.7" }

View File

@ -31,8 +31,7 @@ pub use self::redirect::Redirection;
pub use self::streaming::StreamingHandler; pub use self::streaming::StreamingHandler;
use std::iter; use std::iter;
use util::Itertools; use itertools::Itertools;
use url::Url; use url::Url;
use hyper::{server, header, net, uri}; use hyper::{server, header, net, uri};
use {apps, address, Embeddable}; use {apps, address, Embeddable};

View File

@ -22,6 +22,7 @@
extern crate base32; extern crate base32;
extern crate futures; extern crate futures;
extern crate futures_cpupool; extern crate futures_cpupool;
extern crate itertools;
extern crate linked_hash_map; extern crate linked_hash_map;
extern crate mime_guess; extern crate mime_guess;
extern crate ntp; extern crate ntp;

View File

@ -19,6 +19,7 @@
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::sync::Arc; use std::sync::Arc;
use std::mem; use std::mem;
use itertools::Itertools;
use bloomchain as bc; use bloomchain as bc;
use util::*; use util::*;
use rlp::*; use rlp::*;

View File

@ -20,9 +20,10 @@ use std::sync::{Arc, Weak};
use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering}; use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering};
use std::time::{Instant}; use std::time::{Instant};
use time::precise_time_ns; use time::precise_time_ns;
use itertools::Itertools;
// util // util
use util::{Bytes, PerfTimer, Itertools, Mutex, RwLock, MutexGuard, Hashable}; use util::{Bytes, PerfTimer, Mutex, RwLock, MutexGuard, Hashable};
use util::{journaldb, DBValue, TrieFactory, Trie}; use util::{journaldb, DBValue, TrieFactory, Trie};
use util::{U256, H256, Address, H2048}; use util::{U256, H256, Address, H2048};
use util::trie::TrieSpec; use util::trie::TrieSpec;

View File

@ -20,6 +20,7 @@ use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrder};
use std::sync::Arc; use std::sync::Arc;
use std::collections::{HashMap, BTreeMap}; use std::collections::{HashMap, BTreeMap};
use std::mem; use std::mem;
use itertools::Itertools;
use rustc_hex::FromHex; use rustc_hex::FromHex;
use util::*; use util::*;
use rlp::*; use rlp::*;

View File

@ -15,6 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::collections::BTreeMap; use std::collections::BTreeMap;
use itertools::Itertools;
use block::{OpenBlock, SealedBlock, ClosedBlock}; use block::{OpenBlock, SealedBlock, ClosedBlock};
use blockchain::TreeRoute; use blockchain::TreeRoute;
@ -33,7 +34,7 @@ use trace::LocalizedTrace;
use transaction::{LocalizedTransaction, PendingTransaction, SignedTransaction}; use transaction::{LocalizedTransaction, PendingTransaction, SignedTransaction};
use verification::queue::QueueInfo as BlockQueueInfo; use verification::queue::QueueInfo as BlockQueueInfo;
use util::{U256, Address, H256, H2048, Bytes, Itertools}; use util::{U256, Address, H256, H2048, Bytes};
use util::hashdb::DBValue; use util::hashdb::DBValue;
use types::ids::*; use types::ids::*;

View File

@ -16,6 +16,7 @@
use std::fmt; use std::fmt;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use itertools::Itertools;
use util::*; use util::*;
use state::Account; use state::Account;
use ethjson; use ethjson;

View File

@ -18,6 +18,7 @@
use std::fmt; use std::fmt;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use itertools::Itertools;
use util::*; use util::*;
use pod_account::{self, PodAccount}; use pod_account::{self, PodAccount};
use types::state_diff::StateDiff; use types::state_diff::StateDiff;

View File

@ -24,6 +24,7 @@ serde_json = "1.0"
time = "0.1" time = "0.1"
tokio-timer = "0.1" tokio-timer = "0.1"
transient-hashmap = "0.4" transient-hashmap = "0.4"
itertools = "0.5"
jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.7" } jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.7" }
jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.7" } jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.7" }

View File

@ -18,9 +18,10 @@ use std::io::{self, Read, Write};
use std::path::Path; use std::path::Path;
use std::{fs, time, mem}; use std::{fs, time, mem};
use itertools::Itertools;
use rand::Rng; use rand::Rng;
use rand::os::OsRng; use rand::os::OsRng;
use util::{H256, Hashable, Itertools}; use util::{H256, Hashable};
/// Providing current time in seconds /// Providing current time in seconds
pub trait TimeProvider { pub trait TimeProvider {

View File

@ -24,6 +24,7 @@ extern crate cid;
extern crate crypto as rust_crypto; extern crate crypto as rust_crypto;
extern crate futures; extern crate futures;
extern crate futures_cpupool; extern crate futures_cpupool;
extern crate itertools;
extern crate multihash; extern crate multihash;
extern crate order_stat; extern crate order_stat;
extern crate rand; extern crate rand;

View File

@ -19,7 +19,6 @@ rust-crypto = "0.2.34"
elastic-array = "0.9" elastic-array = "0.9"
rlp = { path = "rlp" } rlp = { path = "rlp" }
heapsize = "0.4" heapsize = "0.4"
itertools = "0.5"
sha3 = { path = "sha3" } sha3 = { path = "sha3" }
clippy = { version = "0.0.103", optional = true} clippy = { version = "0.0.103", optional = true}
ethcore-devtools = { path = "../devtools" } 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); assert!(min_count + diff_count <= 32);
*seed = seed.sha3(); *seed = seed.sha3();
let r = min_count + (seed[31] as usize % (diff_count + 1)); 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 { fn random_value(seed: &mut H256) -> Bytes {
*seed = seed.sha3(); *seed = seed.sha3();
match seed[0] % 2 { match seed[0] % 2 {
1 => vec![seed[31];1], 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 std::sync::Arc;
use parking_lot::RwLock; use parking_lot::RwLock;
use heapsize::HeapSizeOf; use heapsize::HeapSizeOf;
use itertools::Itertools;
use rlp::*; use rlp::*;
use hashdb::*; use hashdb::*;
use memorydb::*; use memorydb::*;
@ -432,7 +431,9 @@ impl JournalDB for EarlyMergeDB {
// - we write the key into our journal for this block; // - we write the key into our journal for this block;
r.begin_list(inserts.len()); r.begin_list(inserts.len());
inserts.iter().foreach(|&(k, _)| {r.append(&k);}); for &(k, _) in &inserts {
r.append(&k);
}
r.append_list(&removes); r.append_list(&removes);
Self::insert_keys(&inserts, &*self.backing, self.column, &mut refs, batch, trace); 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 regex;
extern crate lru_cache; extern crate lru_cache;
extern crate heapsize; extern crate heapsize;
extern crate itertools;
extern crate ethcore_logger; extern crate ethcore_logger;
#[macro_use] #[macro_use]
@ -153,7 +152,6 @@ pub use bigint::hash;
pub use ansi_term::{Colour, Style}; pub use ansi_term::{Colour, Style};
pub use heapsize::HeapSizeOf; pub use heapsize::HeapSizeOf;
pub use itertools::Itertools;
pub use parking_lot::{Condvar, Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard}; pub use parking_lot::{Condvar, Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
/// 160-bit integer representing account address /// 160-bit integer representing account address

View File

@ -15,7 +15,6 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::fmt; use std::fmt;
use itertools::Itertools;
use hashdb::*; use hashdb::*;
use nibbleslice::*; use nibbleslice::*;
use rlp::*; use rlp::*;
@ -293,7 +292,18 @@ impl<'a> TrieDBIterator<'a> {
/// The present key. /// The present key.
fn key(&self) -> Bytes { fn key(&self) -> Bytes {
// collapse the key_nibbles down to 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
}
} }
} }