diff options
author | evan <github@evan.lol> | 2022-01-10 18:51:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-10 15:51:23 -0800 |
commit | b66afa2518042cda239ef07f221722781ca660f6 (patch) | |
tree | 629ebc8c74496df7bf1588e2e4f5ec06fcb4e788 /cli/tsc.rs | |
parent | a3b3a792b5c8dd2fa3e1b29f7fe5a7f3423f25c0 (diff) |
feat(cli, runtime): compress snapshots (#13320)
Diffstat (limited to 'cli/tsc.rs')
-rw-r--r-- | cli/tsc.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/cli/tsc.rs b/cli/tsc.rs index 3dfb97588..a2265e36f 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -51,11 +51,25 @@ pub static SHARED_GLOBALS_LIB: &str = pub static WINDOW_LIB: &str = include_str!("dts/lib.deno.window.d.ts"); pub static UNSTABLE_NS_LIB: &str = include_str!("dts/lib.deno.unstable.d.ts"); -pub static COMPILER_SNAPSHOT: &[u8] = - include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.bin")); +pub static COMPILER_SNAPSHOT: Lazy<Box<[u8]>> = Lazy::new( + #[cold] + #[inline(never)] + || { + static COMPRESSED_COMPILER_SNAPSHOT: &[u8] = + include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.bin")); + + zstd::block::decompress( + &COMPRESSED_COMPILER_SNAPSHOT[4..], + u32::from_le_bytes(COMPRESSED_COMPILER_SNAPSHOT[0..4].try_into().unwrap()) + as usize, + ) + .unwrap() + .into_boxed_slice() + }, +); pub fn compiler_snapshot() -> Snapshot { - Snapshot::Static(COMPILER_SNAPSHOT) + Snapshot::Static(&*COMPILER_SNAPSHOT) } macro_rules! inc { |