@@ -51,13 +51,6 @@ macro_rules! write_leb128 {
5151 } } ;
5252}
5353
54- /// A byte that [cannot occur in UTF8 sequences][utf8]. Used to mark the end of a string.
55- /// This way we can skip validation and still be relatively sure that deserialization
56- /// did not desynchronize.
57- ///
58- /// [utf8]: https://en.wikipedia.org/w/index.php?title=UTF-8&oldid=1058865525#Codepage_layout
59- const STR_SENTINEL : u8 = 0xC1 ;
60-
6154impl Encoder for MemEncoder {
6255 #[ inline]
6356 fn emit_usize ( & mut self , v : usize ) {
@@ -114,28 +107,6 @@ impl Encoder for MemEncoder {
114107 self . data . extend_from_slice ( & v. to_le_bytes ( ) ) ;
115108 }
116109
117- #[ inline]
118- fn emit_i8 ( & mut self , v : i8 ) {
119- self . emit_u8 ( v as u8 ) ;
120- }
121-
122- #[ inline]
123- fn emit_bool ( & mut self , v : bool ) {
124- self . emit_u8 ( if v { 1 } else { 0 } ) ;
125- }
126-
127- #[ inline]
128- fn emit_char ( & mut self , v : char ) {
129- self . emit_u32 ( v as u32 ) ;
130- }
131-
132- #[ inline]
133- fn emit_str ( & mut self , v : & str ) {
134- self . emit_usize ( v. len ( ) ) ;
135- self . emit_raw_bytes ( v. as_bytes ( ) ) ;
136- self . emit_u8 ( STR_SENTINEL ) ;
137- }
138-
139110 #[ inline]
140111 fn emit_raw_bytes ( & mut self , s : & [ u8 ] ) {
141112 self . data . extend_from_slice ( s) ;
@@ -480,28 +451,6 @@ impl Encoder for FileEncoder {
480451 self . write_all ( & v. to_le_bytes ( ) ) ;
481452 }
482453
483- #[ inline]
484- fn emit_i8 ( & mut self , v : i8 ) {
485- self . emit_u8 ( v as u8 ) ;
486- }
487-
488- #[ inline]
489- fn emit_bool ( & mut self , v : bool ) {
490- self . emit_u8 ( if v { 1 } else { 0 } ) ;
491- }
492-
493- #[ inline]
494- fn emit_char ( & mut self , v : char ) {
495- self . emit_u32 ( v as u32 ) ;
496- }
497-
498- #[ inline]
499- fn emit_str ( & mut self , v : & str ) {
500- self . emit_usize ( v. len ( ) ) ;
501- self . emit_raw_bytes ( v. as_bytes ( ) ) ;
502- self . emit_u8 ( STR_SENTINEL ) ;
503- }
504-
505454 #[ inline]
506455 fn emit_raw_bytes ( & mut self , s : & [ u8 ] ) {
507456 self . write_all ( s) ;
@@ -665,36 +614,11 @@ impl<'a> Decoder for MemDecoder<'a> {
665614 i16:: from_le_bytes ( self . read_array ( ) )
666615 }
667616
668- #[ inline]
669- fn read_i8 ( & mut self ) -> i8 {
670- self . read_byte ( ) as i8
671- }
672-
673617 #[ inline]
674618 fn read_isize ( & mut self ) -> isize {
675619 read_leb128 ! ( self , read_isize_leb128)
676620 }
677621
678- #[ inline]
679- fn read_bool ( & mut self ) -> bool {
680- let value = self . read_u8 ( ) ;
681- value != 0
682- }
683-
684- #[ inline]
685- fn read_char ( & mut self ) -> char {
686- let bits = self . read_u32 ( ) ;
687- std:: char:: from_u32 ( bits) . unwrap ( )
688- }
689-
690- #[ inline]
691- fn read_str ( & mut self ) -> & str {
692- let len = self . read_usize ( ) ;
693- let bytes = self . read_raw_bytes ( len + 1 ) ;
694- assert ! ( bytes[ len] == STR_SENTINEL ) ;
695- unsafe { std:: str:: from_utf8_unchecked ( & bytes[ ..len] ) }
696- }
697-
698622 #[ inline]
699623 fn read_raw_bytes ( & mut self , bytes : usize ) -> & ' a [ u8 ] {
700624 if bytes > self . remaining ( ) {
0 commit comments