@@ -147,13 +147,13 @@ impl<'de, R: Read<'de>> Deserializer<R> {
147
147
}
148
148
149
149
/// Error caused by a byte from next_char().
150
- fn error ( & mut self , reason : ErrorCode ) -> Error {
150
+ fn error ( & self , reason : ErrorCode ) -> Error {
151
151
let pos = self . read . position ( ) ;
152
152
Error :: syntax ( reason, pos. line , pos. column )
153
153
}
154
154
155
155
/// Error caused by a byte from peek().
156
- fn peek_error ( & mut self , reason : ErrorCode ) -> Error {
156
+ fn peek_error ( & self , reason : ErrorCode ) -> Error {
157
157
let pos = self . read . peek_position ( ) ;
158
158
Error :: syntax ( reason, pos. line , pos. column )
159
159
}
@@ -256,10 +256,15 @@ impl<'de, R: Read<'de>> Deserializer<R> {
256
256
// tell whether this should call `error` or `peek_error` so pick the
257
257
// one that seems correct more often. Worst case, the position is
258
258
// off by one character.
259
- Err ( err) => Err ( err . fix_position ( |code| self . error ( code ) ) ) ,
259
+ Err ( err) => Err ( self . fix_position ( err ) ) ,
260
260
}
261
261
}
262
262
263
+ #[ cold]
264
+ fn fix_position ( & self , err : Error ) -> Error {
265
+ err. fix_position ( move |code| self . error ( code) )
266
+ }
267
+
263
268
fn parse_ident ( & mut self , ident : & [ u8 ] ) -> Result < ( ) > {
264
269
for c in ident {
265
270
if Some ( * c) != try!( self . next_char ( ) ) {
0 commit comments