diff options
| author | Simonas Kazlauskas <github@kazlauskas.me> | 2015-12-31 17:28:57 +0200 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2015-12-31 18:52:20 +0200 |
| commit | 23d24ff6678c601774a24500700f7380a2c34ad4 (patch) | |
| tree | 8565a2fadc5719a7679a224816b92a66eb14f6cd /src/libsyntax | |
| parent | ad3371aedbf3c2addb105d7997a27311cbcf42e2 (diff) | |
| parent | fa2a7411e403ec31b426c339c9950af8a1037995 (diff) | |
| download | rust-23d24ff6678c601774a24500700f7380a2c34ad4.tar.gz rust-23d24ff6678c601774a24500700f7380a2c34ad4.zip | |
Rollup merge of #30565 - michaelwoerister:opaque_encoder, r=brson
This PR changes the `emit_opaque` and `read_opaque` methods in the RBML library to use a space-efficient binary encoder that does not emit any tags and uses the LEB128 variable-length integer format for all numbers it emits. The space savings are nice, albeit a bit underwhelming, especially for dynamic libraries where metadata is already compressed. | RLIBs | NEW | OLD | |--------------|--------|-----------| |libstd | 8.8 MB | 10.5 MB | |libcore |15.6 MB | 19.7 MB | |libcollections| 3.7 MB | 4.8 MB | |librustc |34.0 MB | 37.8 MB | |libsyntax |28.3 MB | 32.1 MB | | SOs | NEW | OLD | |---------------|-----------|--------| | libstd | 4.8 MB | 5.1 MB | | librustc | 8.6 MB | 9.2 MB | | libsyntax | 7.8 MB | 8.4 MB | At least this should make up for the size increase caused recently by also storing MIR in crate metadata. Can this be a breaking change for anyone? cc @rust-lang/compiler
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 18659cb2e78..19236f2cd98 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -164,18 +164,15 @@ impl Eq for Span {} impl Encodable for Span { fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - // Encode spans as a single u64 in order to cut down on tagging overhead - // added by the RBML metadata encoding. The should be solved differently - // altogether some time (FIXME #21482) - s.emit_u64( (self.lo.0 as u64) | ((self.hi.0 as u64) << 32) ) + try!(s.emit_u32(self.lo.0)); + s.emit_u32(self.hi.0) } } impl Decodable for Span { fn decode<D: Decoder>(d: &mut D) -> Result<Span, D::Error> { - let lo_hi: u64 = try! { d.read_u64() }; - let lo = BytePos(lo_hi as u32); - let hi = BytePos((lo_hi >> 32) as u32); + let lo = BytePos(try! { d.read_u32() }); + let hi = BytePos(try! { d.read_u32() }); Ok(mk_sp(lo, hi)) } } |
