diff options
| author | Michael Howell <michael@notriddle.com> | 2023-01-24 15:39:59 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2023-01-26 10:51:10 -0700 |
| commit | 51df99f3c2bac3ee7158b115ff6d54b687d018e1 (patch) | |
| tree | 846756fe9cebbb9d96234b6038e8fc4549cd7fc5 /src/librustdoc/html | |
| parent | c8e6a9e8b6251bbc8276cb78cabe1998deecbed7 (diff) | |
| download | rust-51df99f3c2bac3ee7158b115ff6d54b687d018e1.tar.gz rust-51df99f3c2bac3ee7158b115ff6d54b687d018e1.zip | |
rustdoc: use smarter encoding for playground URL
The old way would compress okay with DEFLATE, but this version makes
uncompressed docs smaller, which matters for memory usage and stuff
like `cargo doc`.
Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}>
In local testing, this change shrinks sample pages by anywhere between
4.0% and 0.031%
$ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html
759235 after.dir/std/vec/struct.Vec.html
781842 before.dir/std/vec/struct.Vec.html
100*((759235-781842)/781842)=-2.8
$ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html
3194173 after.dir/std/num/struct.Wrapping.html
3204351 before.dir/std/num/struct.Wrapping.html
100*((3194173-3204351)/3204351)=-0.031
$ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html
8151 after.dir/std/keyword.match.html
8495 before.dir/std/keyword.match.html
100*((8151-8495)/8495)=-4.0
Gzipped tarball sizes seem shrunk, but not by much.
du -s before.tar.gz after.tar.gz
69600 before.tar.gz
69480 after.tar.gz
100*((69480-69600)/69600)=-0.17
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/markdown.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 4ff67fe1551..b1efbf4bdca 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -296,7 +296,9 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> { let channel = if test.contains("#