Skip to content

Commit 2f3aa0d

Browse files
committed
metadata: Eliminate the EsEnumBody tag.
It doesn't serve any useful purpose. It *might* be useful when there are some tags that are generated by `Encodable` and not delimited by any tags, but IIUC it's not the case. Previous: <-------------------- len1 -------------------> EsEnum <len1> EsEnumVid <vid> EsEnumBody <len2> <arg1> <arg2> <--- len2 --> Now: <----------- len1 ----------> EsEnum <len1> EsEnumVid <vid> <arg1> <arg2>
1 parent c9840b6 commit 2f3aa0d

File tree

1 file changed

+12
-35
lines changed

1 file changed

+12
-35
lines changed

src/librbml/lib.rs

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,16 @@ pub enum EbmlEncoderTag {
103103

104104
EsStr = 0x11,
105105
EsEnum = 0x12,
106-
EsEnumBody = 0x13,
107-
EsVec = 0x14,
108-
EsVecElt = 0x15,
109-
EsMap = 0x16,
110-
EsMapKey = 0x17,
111-
EsMapVal = 0x18,
106+
EsVec = 0x13,
107+
EsVecElt = 0x14,
108+
EsMap = 0x15,
109+
EsMapKey = 0x16,
110+
EsMapVal = 0x17,
112111

113-
EsOpaque = 0x19,
112+
EsOpaque = 0x18,
114113

115114
// Used only when debugging
116-
EsLabel = 0x1a,
115+
EsLabel = 0x19,
117116
}
118117

119118
const NUM_TAGS: uint = 0x1000;
@@ -160,7 +159,7 @@ pub mod reader {
160159
use super::{ ApplicationError, EsVec, EsMap, EsEnum, EsVecLen, EsVecElt,
161160
EsMapLen, EsMapKey, EsEnumVid, EsU64, EsU32, EsU16, EsU8, EsInt, EsI64,
162161
EsI32, EsI16, EsI8, EsBool, EsF64, EsF32, EsChar, EsStr, EsMapVal,
163-
EsEnumBody, EsUint, EsOpaque, EsLabel, EbmlEncoderTag, Doc, TaggedDoc,
162+
EsUint, EsOpaque, EsLabel, EbmlEncoderTag, Doc, TaggedDoc,
164163
Error, IntTooBig, InvalidTag, Expected, NUM_IMPLICIT_TAGS, TAG_IMPLICIT_LEN };
165164

166165
pub type DecodeResult<T> = Result<T, Error>;
@@ -564,17 +563,7 @@ pub mod reader {
564563
let idx = try!(self._next_uint(EsEnumVid));
565564
debug!(" idx={}", idx);
566565

567-
let doc = try!(self.next_doc(EsEnumBody));
568-
569-
let (old_parent, old_pos) = (self.parent, self.pos);
570-
self.parent = doc;
571-
self.pos = self.parent.start;
572-
573-
let result = try!(f(self, idx));
574-
575-
self.parent = old_parent;
576-
self.pos = old_pos;
577-
Ok(result)
566+
f(self, idx)
578567
}
579568

580569
fn read_enum_variant_arg<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
@@ -592,17 +581,7 @@ pub mod reader {
592581
let idx = try!(self._next_uint(EsEnumVid));
593582
debug!(" idx={}", idx);
594583

595-
let doc = try!(self.next_doc(EsEnumBody));
596-
597-
let (old_parent, old_pos) = (self.parent, self.pos);
598-
self.parent = doc;
599-
self.pos = self.parent.start;
600-
601-
let result = try!(f(self, idx));
602-
603-
self.parent = old_parent;
604-
self.pos = old_pos;
605-
Ok(result)
584+
f(self, idx)
606585
}
607586

608587
fn read_enum_struct_variant_field<T, F>(&mut self,
@@ -743,7 +722,7 @@ pub mod writer {
743722

744723
use super::{ EsVec, EsMap, EsEnum, EsVecLen, EsVecElt, EsMapLen, EsMapKey,
745724
EsEnumVid, EsU64, EsU32, EsU16, EsU8, EsInt, EsI64, EsI32, EsI16, EsI8,
746-
EsBool, EsF64, EsF32, EsChar, EsStr, EsMapVal, EsEnumBody, EsUint,
725+
EsBool, EsF64, EsF32, EsChar, EsStr, EsMapVal, EsUint,
747726
EsOpaque, EsLabel, EbmlEncoderTag, NUM_IMPLICIT_TAGS, NUM_TAGS };
748727

749728
use serialize;
@@ -1059,9 +1038,7 @@ pub mod writer {
10591038
F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
10601039
{
10611040
try!(self._emit_tagged_uint(EsEnumVid, v_id));
1062-
try!(self.start_tag(EsEnumBody as uint));
1063-
try!(f(self));
1064-
self.end_tag()
1041+
f(self)
10651042
}
10661043

10671044
fn emit_enum_variant_arg<F>(&mut self, _: uint, f: F) -> EncodeResult where

0 commit comments

Comments
 (0)