Upgrade elastic-array to 0.9.0

This is a huge change, which includes some changes to replace code that
originally cloned to reuse allocations instead. The updated
`elastic-array` crate renames its consuming `Vec`-conversion method to
`into_vec`, which means that I can do a simple
`sed -i 's/to_vec/into_vec/'` and then fix the compilation errors.

This commit is probably a minor performance win and definitely a
significant readability win.
This commit is contained in:
Vurich
2017-06-28 14:16:53 +02:00
parent 826bf28196
commit 3d8dc11442
76 changed files with 212 additions and 211 deletions

View File

@@ -266,7 +266,7 @@ impl BlockProvider for BlockChain {
let result = match opt {
Some(b) => {
let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).to_vec();
let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).into_vec();
let mut write = self.block_headers.write();
write.insert(hash.clone(), bytes.clone());
Some(encoded::Header::new(bytes))
@@ -302,7 +302,7 @@ impl BlockProvider for BlockChain {
let result = match opt {
Some(b) => {
let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).to_vec();
let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).into_vec();
let mut write = self.block_bodies.write();
write.insert(hash.clone(), bytes.clone());
Some(encoded::Body::new(bytes))
@@ -536,7 +536,7 @@ impl BlockChain {
let best_block_rlp = bc.block(&best_block_hash).unwrap().into_inner();
let best_block_timestamp = BlockView::new(&best_block_rlp).header().timestamp();
let raw_first = bc.db.get(db::COL_EXTRA, b"first").unwrap().map(|v| v.to_vec());
let raw_first = bc.db.get(db::COL_EXTRA, b"first").unwrap().map(|v| v.into_vec());
let mut best_ancient = bc.db.get(db::COL_EXTRA, b"ancient").unwrap().map(|h| H256::from_slice(&h));
let best_ancient_number;
if best_ancient.is_none() && best_block_number > 1 && bc.block_hash(1).is_none() {

View File

@@ -67,6 +67,6 @@ impl WithTransaction for Block {
impl CompleteBlock for Block {
fn complete(mut self, parent_hash: H256) -> Bytes {
self.header.set_parent_hash(parent_hash);
encode(&self).to_vec()
encode(&self).into_vec()
}
}