expunge &Vec<T> pattern (#1579)

* expunge &Vec<T> pattern

* fix travis
This commit is contained in:
Robert Habermeier
2016-07-12 10:28:35 +02:00
committed by Gav Wood
parent 92fd00f41e
commit 7200cfcbc9
13 changed files with 48 additions and 49 deletions

View File

@@ -16,8 +16,6 @@
//! Blockchain block.
#![cfg_attr(feature="dev", allow(ptr_arg))] // Because of &LastHashes -> &Vec<_>
use common::*;
use engine::*;
use state::*;
@@ -76,11 +74,11 @@ pub struct BlockRefMut<'a> {
/// Block header.
pub header: &'a mut Header,
/// Block transactions.
pub transactions: &'a Vec<SignedTransaction>,
pub transactions: &'a [SignedTransaction],
/// Block uncles.
pub uncles: &'a Vec<Header>,
pub uncles: &'a [Header],
/// Transaction receipts.
pub receipts: &'a Vec<Receipt>,
pub receipts: &'a [Receipt],
/// State.
pub state: &'a mut State,
/// Traces.
@@ -92,11 +90,11 @@ pub struct BlockRef<'a> {
/// Block header.
pub header: &'a Header,
/// Block transactions.
pub transactions: &'a Vec<SignedTransaction>,
pub transactions: &'a [SignedTransaction],
/// Block uncles.
pub uncles: &'a Vec<Header>,
pub uncles: &'a [Header],
/// Transaction receipts.
pub receipts: &'a Vec<Receipt>,
pub receipts: &'a [Receipt],
/// State.
pub state: &'a State,
/// Traces.
@@ -152,16 +150,16 @@ pub trait IsBlock {
fn state(&self) -> &State { &self.block().state }
/// Get all information on transactions in this block.
fn transactions(&self) -> &Vec<SignedTransaction> { &self.block().base.transactions }
fn transactions(&self) -> &[SignedTransaction] { &self.block().base.transactions }
/// Get all information on receipts in this block.
fn receipts(&self) -> &Vec<Receipt> { &self.block().receipts }
fn receipts(&self) -> &[Receipt] { &self.block().receipts }
/// Get all information concerning transaction tracing in this block.
fn traces(&self) -> &Option<Vec<Trace>> { &self.block().traces }
/// Get all uncles in this block.
fn uncles(&self) -> &Vec<Header> { &self.block().base.uncles }
fn uncles(&self) -> &[Header] { &self.block().base.uncles }
}
/// Trait for a object that has a state database.

View File

@@ -426,7 +426,7 @@ impl Client {
};
// Commit results
let receipts = block.receipts().clone();
let receipts = block.receipts().to_owned();
let traces = From::from(block.traces().clone().unwrap_or_else(Vec::new));
// CHECK! I *think* this is fine, even if the state_root is equal to another

View File

@@ -143,7 +143,7 @@ impl Header {
/// Get the difficulty field of the header.
pub fn difficulty(&self) -> &U256 { &self.difficulty }
/// Get the seal field of the header.
pub fn seal(&self) -> &Vec<Bytes> { &self.seal }
pub fn seal(&self) -> &[Bytes] { &self.seal }
// TODO: seal_at, set_seal_at &c.

View File

@@ -665,7 +665,7 @@ impl MinerService for Miner {
};
match (&self.options.pending_set, sealing_set) {
(&PendingSet::AlwaysQueue, _) | (&PendingSet::SealingOrElseQueue, None) => queue.top_transactions(),
(_, sealing) => sealing.map_or_else(Vec::new, |s| s.transactions().clone()),
(_, sealing) => sealing.map_or_else(Vec::new, |s| s.transactions().to_owned()),
}
}
@@ -702,7 +702,7 @@ impl MinerService for Miner {
.iter()
.map(|t| t.hash());
let receipts = pending.receipts().clone().into_iter();
let receipts = pending.receipts().iter().cloned();
hashes.zip(receipts).collect()
},

View File

@@ -143,7 +143,7 @@ impl Spec {
}
/// Get the known knodes of the network in enode format.
pub fn nodes(&self) -> &Vec<String> { &self.nodes }
pub fn nodes(&self) -> &[String] { &self.nodes }
/// Get the configured Network ID.
pub fn network_id(&self) -> U256 { self.params.network_id }