From 6e917c080047413a5fb8ba537913a2bf2d63c02e Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Wed, 21 May 2014 21:48:34 -0700 Subject: [PATCH] Make sure to inline things in the Decoders 169ns vs 190ns, 346ns vs 329ns --- de.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/de.rs b/de.rs index ac9a2c36..411333b4 100644 --- a/de.rs +++ b/de.rs @@ -785,6 +785,7 @@ mod tests { fn read_f64(&mut self) -> Result { Err(SyntaxError) } fn read_f32(&mut self) -> Result { Err(SyntaxError) } fn read_char(&mut self) -> Result { Err(SyntaxError) } + #[inline] fn read_str(&mut self) -> Result { match self.stack.pop() { Some(AnimalDecoderStrState(x)) => Ok(x), @@ -793,6 +794,7 @@ mod tests { } // Compound types: + #[inline] fn read_enum(&mut self, name: &str, f: |&mut AnimalDecoder| -> Result) -> Result { match self.stack.pop() { Some(AnimalDecoderAnimalState(animal)) => { @@ -807,6 +809,7 @@ mod tests { } } + #[inline] fn read_enum_variant(&mut self, names: &[&str], f: |&mut AnimalDecoder, uint| -> Result) -> Result { let name = match self.stack.pop() { Some(AnimalDecoderAnimalState(Dog)) => "Dog", @@ -825,6 +828,7 @@ mod tests { f(self, idx) } + #[inline] fn read_enum_variant_arg(&mut self, _a_idx: uint, f: |&mut AnimalDecoder| -> Result) -> Result { f(self) }