diff --git a/src/libserialize/collection_impls.rs b/src/libserialize/collection_impls.rs index da705081ff34d..9748a5063925b 100644 --- a/src/libserialize/collection_impls.rs +++ b/src/libserialize/collection_impls.rs @@ -17,9 +17,7 @@ use std::collections::{LinkedList, VecDeque, BTreeMap, BTreeSet, HashMap, HashSe use std::rc::Rc; use std::sync::Arc; -impl< - T: Encodable -> Encodable for LinkedList { +impl Encodable for LinkedList { fn encode(&self, s: &mut S) -> Result<(), S::Error> { s.emit_seq(self.len(), |s| { for (i, e) in self.iter().enumerate() { @@ -65,10 +63,10 @@ impl Decodable for VecDeque { } } -impl< - K: Encodable + PartialEq + Ord, - V: Encodable -> Encodable for BTreeMap { +impl Encodable for BTreeMap + where K: Encodable + PartialEq + Ord, + V: Encodable +{ fn encode(&self, e: &mut S) -> Result<(), S::Error> { e.emit_map(self.len(), |e| { let mut i = 0; @@ -82,10 +80,10 @@ impl< } } -impl< - K: Decodable + PartialEq + Ord, - V: Decodable -> Decodable for BTreeMap { +impl Decodable for BTreeMap + where K: Decodable + PartialEq + Ord, + V: Decodable +{ fn decode(d: &mut D) -> Result, D::Error> { d.read_map(|d, len| { let mut map = BTreeMap::new(); @@ -99,9 +97,9 @@ impl< } } -impl< - T: Encodable + PartialEq + Ord -> Encodable for BTreeSet { +impl Encodable for BTreeSet + where T: Encodable + PartialEq + Ord +{ fn encode(&self, s: &mut S) -> Result<(), S::Error> { s.emit_seq(self.len(), |s| { let mut i = 0; @@ -114,9 +112,9 @@ impl< } } -impl< - T: Decodable + PartialEq + Ord -> Decodable for BTreeSet { +impl Decodable for BTreeSet + where T: Decodable + PartialEq + Ord +{ fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut set = BTreeSet::new(); diff --git a/src/libserialize/leb128.rs b/src/libserialize/leb128.rs index eee95d9fa6777..e02bc5e1025fd 100644 --- a/src/libserialize/leb128.rs +++ b/src/libserialize/leb128.rs @@ -118,6 +118,7 @@ pub fn write_signed_leb128_to(mut value: i128, mut write: W) } } +#[inline] pub fn write_signed_leb128(out: &mut Vec, value: i128) { write_signed_leb128_to(value, |v| write_to_vec(out, v)) } diff --git a/src/libserialize/opaque.rs b/src/libserialize/opaque.rs index a77d1d9b88b89..c71f474891131 100644 --- a/src/libserialize/opaque.rs +++ b/src/libserialize/opaque.rs @@ -31,6 +31,7 @@ impl Encoder { self.data } + #[inline] pub fn emit_raw_bytes(&mut self, s: &[u8]) { self.data.extend_from_slice(s); } @@ -193,6 +194,7 @@ impl<'a> Decoder<'a> { self.position += bytes; } + #[inline] pub fn read_raw_bytes(&mut self, s: &mut [u8]) -> Result<(), String> { let start = self.position; let end = start + s.len(); @@ -326,6 +328,7 @@ impl<'a> serialize::Decoder for Decoder<'a> { Ok(Cow::Borrowed(s)) } + #[inline] fn error(&mut self, err: &str) -> Self::Error { err.to_string() } diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index ed94194ffcc05..60bb5a0fec2cd 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -119,6 +119,7 @@ pub trait Encoder { self.emit_enum("Option", f) } + #[inline] fn emit_option_none(&mut self) -> Result<(), Self::Error> { self.emit_enum_variant("None", 0, 0, |_| Ok(())) } @@ -560,14 +561,12 @@ impl< T: Decodable> Decodable for Box<[T]> { } impl Encodable for Rc { - #[inline] fn encode(&self, s: &mut S) -> Result<(), S::Error> { (**self).encode(s) } } impl Decodable for Rc { - #[inline] fn decode(d: &mut D) -> Result, D::Error> { Ok(Rc::new(Decodable::decode(d)?)) } @@ -618,7 +617,9 @@ impl<'a, T:Encodable> Encodable for Cow<'a, [T]> where [T]: ToOwned Decodable for Cow<'static, [T]> where [T]: ToOwned> { +impl Decodable for Cow<'static, [T]> + where [T]: ToOwned> +{ fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut v = Vec::with_capacity(len);