From 32d27697db8c3f408b458f16eb2db1c201644f46 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 12 Oct 2020 00:10:04 +0100 Subject: [PATCH] wee_alloc saves quite a bit of binary size Signed-off-by: Ian Jackson --- Cargo.lock.example | 19 +++++++++++++++++++ wasm/Cargo.toml | 2 ++ wasm/wasm.rs | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/Cargo.lock.example b/Cargo.lock.example index 84b871d0..79fdb2fe 100644 --- a/Cargo.lock.example +++ b/Cargo.lock.example @@ -805,6 +805,12 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + [[package]] name = "mime" version = "0.2.6" @@ -1010,6 +1016,7 @@ dependencies = [ "js-sys", "otter-zcoord", "wasm-bindgen", + "wee_alloc", ] [[package]] @@ -1898,6 +1905,18 @@ version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307" +[[package]] +name = "wee_alloc" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" +dependencies = [ + "cfg-if", + "libc", + "memory_units", + "winapi 0.3.9", +] + [[package]] name = "winapi" version = "0.2.8" diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index 4a355520..58065953 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -17,3 +17,5 @@ otter-zcoord = { path = "../zcoord" } wasm-bindgen = "0.2" js-sys = "0.3" fehler = "1" +wee_alloc = "0.4" +#wee_alloc = { version = "0.4.5", optional = true } diff --git a/wasm/wasm.rs b/wasm/wasm.rs index b84d815c..8d525832 100644 --- a/wasm/wasm.rs +++ b/wasm/wasm.rs @@ -56,3 +56,7 @@ pub fn canary(s: &str) -> JsString { // https://github.com/WebAssembly/binaryen/issues/3006 format!("WASM {}", s).into() } + +//#[cfg(feature = "wee_alloc")] +#[global_allocator] +static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; -- 2.30.2