quick fixes

This commit is contained in:
debris 2015-11-26 02:50:21 +01:00
parent a20d92c03b
commit f0a6376a9e
2 changed files with 16 additions and 2 deletions

View File

@ -10,7 +10,8 @@ extern crate test;
extern crate ethcore_util;
use test::Bencher;
use ethcore_util::rlp::{RlpStream};
use ethcore_util::rlp;
use ethcore_util::rlp::{RlpStream, Rlp, Decodable};
#[bench]
fn bench_stream_value(b: &mut Bencher) {
@ -34,6 +35,19 @@ fn bench_stream_nested_empty_lists(b: &mut Bencher) {
});
}
#[bench]
fn bench_decode_nested_empty_lists(b: &mut Bencher) {
b.iter( || {
// [ [], [[]], [ [], [[]] ] ]
let data = vec![0xc7, 0xc0, 0xc1, 0xc0, 0xc3, 0xc0, 0xc1, 0xc0];
let rlp = Rlp::new(&data);
let v0: Vec<u8> = Decodable::decode(&rlp.at(0).unwrap()).unwrap();
let v1: Vec<Vec<u8>> = Decodable::decode(&rlp.at(1).unwrap()).unwrap();
let v2a: Vec<u8> = Decodable::decode(&rlp.at(2).unwrap().at(0).unwrap()).unwrap();
let v2b: Vec<Vec<u8>> = Decodable::decode(&rlp.at(2).unwrap().at(1).unwrap()).unwrap();
});
}
#[bench]
fn bench_stream_1000_empty_lists(b: &mut Bencher) {
b.iter( || {

View File

@ -262,7 +262,7 @@ impl <T> Decodable for Vec<T> where T: Decodable {
}
}
trait Decoder {
pub trait Decoder {
fn read_value<T>(bytes: &[u8]) -> Result<T, DecoderError> where T: FromBytes;
}