@@ -108,11 +108,7 @@ pub enum EbmlEncoderTag {
108
108
EsMap = 0x15 ,
109
109
EsMapKey = 0x16 ,
110
110
EsMapVal = 0x17 ,
111
-
112
111
EsOpaque = 0x18 ,
113
-
114
- // Used only when debugging
115
- EsLabel = 0x19 ,
116
112
}
117
113
118
114
const NUM_TAGS : uint = 0x1000 ;
@@ -159,7 +155,7 @@ pub mod reader {
159
155
use super :: { ApplicationError , EsVec , EsMap , EsEnum , EsVecLen , EsVecElt ,
160
156
EsMapLen , EsMapKey , EsEnumVid , EsU64 , EsU32 , EsU16 , EsU8 , EsInt , EsI64 ,
161
157
EsI32 , EsI16 , EsI8 , EsBool , EsF64 , EsF32 , EsChar , EsStr , EsMapVal ,
162
- EsUint , EsOpaque , EsLabel , EbmlEncoderTag , Doc , TaggedDoc ,
158
+ EsUint , EsOpaque , EbmlEncoderTag , Doc , TaggedDoc ,
163
159
Error , IntTooBig , InvalidTag , Expected , NUM_IMPLICIT_TAGS , TAG_IMPLICIT_LEN } ;
164
160
165
161
pub type DecodeResult < T > = Result < T , Error > ;
@@ -395,23 +391,6 @@ pub mod reader {
395
391
}
396
392
}
397
393
398
- fn _check_label ( & mut self , lbl : & str ) -> DecodeResult < ( ) > {
399
- if self . pos < self . parent . end {
400
- let TaggedDoc { tag : r_tag, doc : r_doc } =
401
- try!( doc_at ( self . parent . data , self . pos ) ) ;
402
-
403
- if r_tag == ( EsLabel as uint ) {
404
- self . pos = r_doc. end ;
405
- let str = r_doc. as_str_slice ( ) ;
406
- if lbl != str {
407
- return Err ( Expected ( format ! ( "Expected label {:?} but \
408
- found {:?}", lbl, str ) ) ) ;
409
- }
410
- }
411
- }
412
- Ok ( ( ) )
413
- }
414
-
415
394
fn next_doc ( & mut self , exp_tag : EbmlEncoderTag ) -> DecodeResult < Doc < ' doc > > {
416
395
debug ! ( ". next_doc(exp_tag={:?})" , exp_tag) ;
417
396
if self . pos >= self . parent . end {
@@ -540,7 +519,6 @@ pub mod reader {
540
519
F : FnOnce ( & mut Decoder < ' doc > ) -> DecodeResult < T > ,
541
520
{
542
521
debug ! ( "read_enum({})" , name) ;
543
- try!( self . _check_label ( name) ) ;
544
522
545
523
let doc = try!( self . next_doc ( EsEnum ) ) ;
546
524
@@ -606,7 +584,6 @@ pub mod reader {
606
584
F : FnOnce ( & mut Decoder < ' doc > ) -> DecodeResult < T > ,
607
585
{
608
586
debug ! ( "read_struct_field(name={}, idx={})" , name, idx) ;
609
- try!( self . _check_label ( name) ) ;
610
587
f ( self )
611
588
}
612
589
@@ -723,7 +700,7 @@ pub mod writer {
723
700
use super :: { EsVec , EsMap , EsEnum , EsVecLen , EsVecElt , EsMapLen , EsMapKey ,
724
701
EsEnumVid , EsU64 , EsU32 , EsU16 , EsU8 , EsInt , EsI64 , EsI32 , EsI16 , EsI8 ,
725
702
EsBool , EsF64 , EsF32 , EsChar , EsStr , EsMapVal , EsUint ,
726
- EsOpaque , EsLabel , EbmlEncoderTag , NUM_IMPLICIT_TAGS , NUM_TAGS } ;
703
+ EsOpaque , EbmlEncoderTag , NUM_IMPLICIT_TAGS , NUM_TAGS } ;
727
704
728
705
use serialize;
729
706
@@ -928,31 +905,13 @@ pub mod writer {
928
905
// FIXME (#2743): optionally perform "relaxations" on end_tag to more
929
906
// efficiently encode sizes; this is a fixed point iteration
930
907
931
- // Set to true to generate more debugging in EBML code.
932
- // Totally lame approach.
933
- #[ cfg( not( ndebug) ) ]
934
- static DEBUG : bool = true ;
935
- #[ cfg( ndebug) ]
936
- static DEBUG : bool = false ;
937
-
938
908
impl < ' a , W : Writer + Seek > Encoder < ' a , W > {
939
909
// used internally to emit things like the vector length and so on
940
910
fn _emit_tagged_uint ( & mut self , t : EbmlEncoderTag , v : uint ) -> EncodeResult {
941
911
assert ! ( v <= 0xFFFF_FFFF ) ;
942
912
self . wr_tagged_raw_u32 ( t as uint , v as u32 )
943
913
}
944
914
945
- fn _emit_label ( & mut self , label : & str ) -> EncodeResult {
946
- // There are various strings that we have access to, such as
947
- // the name of a record field, which do not actually appear in
948
- // the encoded EBML (normally). This is just for
949
- // efficiency. When debugging, though, we can emit such
950
- // labels and then they will be checked by decoder to
951
- // try and check panics more quickly.
952
- if DEBUG { self . wr_tagged_str ( EsLabel as uint , label) }
953
- else { Ok ( ( ) ) }
954
- }
955
-
956
915
pub fn emit_opaque < F > ( & mut self , f : F ) -> EncodeResult where
957
916
F : FnOnce ( & mut Encoder < W > ) -> EncodeResult ,
958
917
{
@@ -1021,10 +980,9 @@ pub mod writer {
1021
980
self . wr_tagged_str ( EsStr as uint , v)
1022
981
}
1023
982
1024
- fn emit_enum < F > ( & mut self , name : & str , f : F ) -> EncodeResult where
983
+ fn emit_enum < F > ( & mut self , _name : & str , f : F ) -> EncodeResult where
1025
984
F : FnOnce ( & mut Encoder < ' a , W > ) -> EncodeResult ,
1026
985
{
1027
- try!( self . _emit_label ( name) ) ;
1028
986
try!( self . start_tag ( EsEnum as uint ) ) ;
1029
987
try!( f ( self ) ) ;
1030
988
self . end_tag ( )
@@ -1072,10 +1030,9 @@ pub mod writer {
1072
1030
f ( self )
1073
1031
}
1074
1032
1075
- fn emit_struct_field < F > ( & mut self , name : & str , _: uint , f : F ) -> EncodeResult where
1033
+ fn emit_struct_field < F > ( & mut self , _name : & str , _: uint , f : F ) -> EncodeResult where
1076
1034
F : FnOnce ( & mut Encoder < ' a , W > ) -> EncodeResult ,
1077
1035
{
1078
- try!( self . _emit_label ( name) ) ;
1079
1036
f ( self )
1080
1037
}
1081
1038
0 commit comments