added benchmarks and few optimisations for rlp encoding
This commit is contained in:
@@ -60,6 +60,7 @@ impl ToBytes for u64 {
|
||||
fn to_bytes(&self) -> Vec<u8> {
|
||||
let mut res= vec![];
|
||||
let count = self.to_bytes_len();
|
||||
res.reserve(count);
|
||||
for i in 0..count {
|
||||
let j = count - 1 - i;
|
||||
res.push((*self >> (j * 8)) as u8);
|
||||
@@ -89,6 +90,7 @@ macro_rules! impl_uint_to_bytes {
|
||||
fn to_bytes(&self) -> Vec<u8> {
|
||||
let mut res= vec![];
|
||||
let count = self.to_bytes_len();
|
||||
res.reserve(count);
|
||||
for i in 0..count {
|
||||
let j = count - 1 - i;
|
||||
res.push(self.byte(j));
|
||||
|
||||
@@ -233,7 +233,6 @@ macro_rules! construct_uint {
|
||||
type Err = FromHexError;
|
||||
|
||||
fn from_str(value: &str) -> Result<$name, Self::Err> {
|
||||
println!("{}", value);
|
||||
let bytes: &[u8] = &try!(value.from_hex());
|
||||
Ok(From::from(bytes))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user