Skip to content

Commit 7ce6d5f

Browse files
committed
Update deps, replace wee_alloc with lol_alloc
1 parent 16ffdb0 commit 7ce6d5f

File tree

4 files changed

+63
-115
lines changed

4 files changed

+63
-115
lines changed

rust/Cargo.lock

Lines changed: 49 additions & 95 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ crate-type = ["cdylib", "rlib"]
1717
# Biggest hurdle for me in the past were deps relying on some system timer,
1818
# which is not available in WASM land, of course.
1919
[dependencies]
20-
wasm-bindgen = { version = "0.2.82", features = ["serde-serialize", "enable-interning"] }
21-
wasm-bindgen-futures = "0.4.32"
20+
wasm-bindgen = { version = "0.2.83", features = ["serde-serialize", "enable-interning"] }
21+
wasm-bindgen-futures = "0.4.33"
2222

23-
# saves some kilobytes, but might also not result in the fasted code possible
24-
wee_alloc = "0.4.5"
23+
lol_alloc = "0.1.3"
2524

2625
# for printing nicer panics
2726
console_error_panic_hook = "0.1.7"
@@ -32,14 +31,14 @@ serde_json = "1.0.85"
3231
serde-wasm-bindgen = "0.4.3"
3332
base64 = "0.13.0"
3433

35-
js-sys = "0.3.59"
36-
web-sys = { version = "0.3.59", features = ["console"] }
34+
js-sys = "0.3.60"
35+
web-sys = { version = "0.3.60", features = ["console"] }
3736

3837
# if you need something like std::time::Instant::now() in WebAssembly:
3938
# instant = { version = "0.1", features = [ "wasm-bindgen", "now" ] }
4039

4140
[dev-dependencies]
42-
wasm-bindgen-test = "0.3.32"
41+
wasm-bindgen-test = "0.3.33"
4342

4443
[profile.release]
4544
lto = true
@@ -50,7 +49,3 @@ opt-level = "s" # best option so far
5049
# [profile.release.package.'*']
5150
# codegen-units = 1
5251
# opt-level = "s"
53-
54-
# since wasm-bindgen 0.2.70 it should not be needed anymore
55-
# [package.metadata.wasm-pack.profile.release]
56-
# wasm-opt = ["-Oz", "--enable-mutable-globals"]

rust/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
// The wasm_bindgen attribute macros seem to trigger this lint
55
#![allow(clippy::unused_unit)]
66

7+
#[cfg(target_arch = "wasm32")]
8+
use lol_alloc::FreeListAllocator;
9+
10+
#[cfg(target_arch = "wasm32")]
711
#[global_allocator]
8-
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
12+
static ALLOCATOR: FreeListAllocator = FreeListAllocator::new();
913

1014
mod types;
1115

@@ -24,13 +28,13 @@ macro_rules! debug_log {
2428
}
2529
}
2630

27-
#[wasm_bindgen(start, final)]
31+
#[wasm_bindgen(start, skip_typescript)]
2832
pub fn start() {
2933
panic::set_hook(Box::new(console_error_panic_hook::hook));
3034
console::log_1(&intern("(wasm module start)").into());
3135
}
3236

33-
#[wasm_bindgen(final)]
37+
#[wasm_bindgen]
3438
pub async fn handler(event: JsValue, _context: JsValue) -> JsValueResult {
3539
console::log_1(&intern("(wasm handler request call)").into());
3640

rust/src/types/cloudfront.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,5 @@ fn serialize_return<T>(input: &T) -> JsValueResult
256256
where
257257
T: serde::ser::Serialize,
258258
{
259-
// Note: might be not a good idea, because collections are turned into
260-
// ES2015 Maps, which are not JSON stringify'able out of the box
261-
// serde_wasm_bindgen::to_value(input)
262-
// .map_err(|_| intern("could not serialize request struct").into() )
263-
264-
JsValue::from_serde(input).map_err(|_| intern("could not serialize request struct").into())
259+
serde_wasm_bindgen::to_value(input).map_err(|_| intern("could not serialize request struct").into())
265260
}

0 commit comments

Comments
 (0)