Skip to content

Commit 35c798b

Browse files
committed
metadata: Bye bye EsLabel. No regrets.
For the reference, while it is designed to be selectively enabled, it was essentially enabled throughout every snapshot and nightly as far as I can tell. This makes the usefulness of `EsLabel` itself questionable, as it was quite rare that `EsLabel` broke the build. It had consumed about 20~30% of metadata (!) and so this should be a huge win.
1 parent 2f3aa0d commit 35c798b

File tree

1 file changed

+4
-47
lines changed

1 file changed

+4
-47
lines changed

src/librbml/lib.rs

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ pub enum EbmlEncoderTag {
108108
EsMap = 0x15,
109109
EsMapKey = 0x16,
110110
EsMapVal = 0x17,
111-
112111
EsOpaque = 0x18,
113-
114-
// Used only when debugging
115-
EsLabel = 0x19,
116112
}
117113

118114
const NUM_TAGS: uint = 0x1000;
@@ -159,7 +155,7 @@ pub mod reader {
159155
use super::{ ApplicationError, EsVec, EsMap, EsEnum, EsVecLen, EsVecElt,
160156
EsMapLen, EsMapKey, EsEnumVid, EsU64, EsU32, EsU16, EsU8, EsInt, EsI64,
161157
EsI32, EsI16, EsI8, EsBool, EsF64, EsF32, EsChar, EsStr, EsMapVal,
162-
EsUint, EsOpaque, EsLabel, EbmlEncoderTag, Doc, TaggedDoc,
158+
EsUint, EsOpaque, EbmlEncoderTag, Doc, TaggedDoc,
163159
Error, IntTooBig, InvalidTag, Expected, NUM_IMPLICIT_TAGS, TAG_IMPLICIT_LEN };
164160

165161
pub type DecodeResult<T> = Result<T, Error>;
@@ -395,23 +391,6 @@ pub mod reader {
395391
}
396392
}
397393

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-
415394
fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> DecodeResult<Doc<'doc>> {
416395
debug!(". next_doc(exp_tag={:?})", exp_tag);
417396
if self.pos >= self.parent.end {
@@ -540,7 +519,6 @@ pub mod reader {
540519
F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
541520
{
542521
debug!("read_enum({})", name);
543-
try!(self._check_label(name));
544522

545523
let doc = try!(self.next_doc(EsEnum));
546524

@@ -606,7 +584,6 @@ pub mod reader {
606584
F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
607585
{
608586
debug!("read_struct_field(name={}, idx={})", name, idx);
609-
try!(self._check_label(name));
610587
f(self)
611588
}
612589

@@ -723,7 +700,7 @@ pub mod writer {
723700
use super::{ EsVec, EsMap, EsEnum, EsVecLen, EsVecElt, EsMapLen, EsMapKey,
724701
EsEnumVid, EsU64, EsU32, EsU16, EsU8, EsInt, EsI64, EsI32, EsI16, EsI8,
725702
EsBool, EsF64, EsF32, EsChar, EsStr, EsMapVal, EsUint,
726-
EsOpaque, EsLabel, EbmlEncoderTag, NUM_IMPLICIT_TAGS, NUM_TAGS };
703+
EsOpaque, EbmlEncoderTag, NUM_IMPLICIT_TAGS, NUM_TAGS };
727704

728705
use serialize;
729706

@@ -928,31 +905,13 @@ pub mod writer {
928905
// FIXME (#2743): optionally perform "relaxations" on end_tag to more
929906
// efficiently encode sizes; this is a fixed point iteration
930907

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-
938908
impl<'a, W: Writer + Seek> Encoder<'a, W> {
939909
// used internally to emit things like the vector length and so on
940910
fn _emit_tagged_uint(&mut self, t: EbmlEncoderTag, v: uint) -> EncodeResult {
941911
assert!(v <= 0xFFFF_FFFF);
942912
self.wr_tagged_raw_u32(t as uint, v as u32)
943913
}
944914

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-
956915
pub fn emit_opaque<F>(&mut self, f: F) -> EncodeResult where
957916
F: FnOnce(&mut Encoder<W>) -> EncodeResult,
958917
{
@@ -1021,10 +980,9 @@ pub mod writer {
1021980
self.wr_tagged_str(EsStr as uint, v)
1022981
}
1023982

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
1025984
F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
1026985
{
1027-
try!(self._emit_label(name));
1028986
try!(self.start_tag(EsEnum as uint));
1029987
try!(f(self));
1030988
self.end_tag()
@@ -1072,10 +1030,9 @@ pub mod writer {
10721030
f(self)
10731031
}
10741032

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
10761034
F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
10771035
{
1078-
try!(self._emit_label(name));
10791036
f(self)
10801037
}
10811038

0 commit comments

Comments
 (0)