Browse Source

Reduce .wasm size by around 20%

readable-ids
Emil Ernerfeldt 5 years ago
parent
commit
3022231e4f
  1. 4
      Cargo.toml
  2. 16
      docs/example_wasm.js
  3. BIN
      docs/example_wasm_bg.wasm
  4. 8
      emigui/src/containers/menu.rs
  5. 8
      emigui/src/containers/window.rs

4
Cargo.toml

@ -6,3 +6,7 @@ members = [
"example_glium",
"example_wasm",
]
[profile.release]
lto = true # very slightly smaller wasm
opt-level = 's' # 10-20% smaller wasm

16
docs/example_wasm.js

@ -492,6 +492,10 @@ async function init(input) {
handleError(e)
}
};
imports.wbg.__wbg_newnoargs_ebdc90c3d1e4e55d = function(arg0, arg1) {
var ret = new Function(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_call_804d3ad7e8acd4d5 = function(arg0, arg1) {
try {
var ret = getObject(arg0).call(getObject(arg1));
@ -500,14 +504,6 @@ async function init(input) {
handleError(e)
}
};
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbg_newnoargs_ebdc90c3d1e4e55d = function(arg0, arg1) {
var ret = new Function(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_globalThis_48a5e9494e623f26 = function() {
try {
var ret = globalThis.globalThis;
@ -580,6 +576,10 @@ async function init(input) {
var ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbg_instanceof_Memory_7ccbf540b50fc2bf = function(arg0) {
var ret = getObject(arg0) instanceof WebAssembly.Memory;
return ret;

BIN
docs/example_wasm_bg.wasm

Binary file not shown.

8
emigui/src/containers/menu.rs

@ -44,6 +44,14 @@ pub fn bar<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> (R, Inter
/// Construct a top level menu in a menu bar. This would be e.g. "File", "Edit" etc.
pub fn menu(ui: &mut Ui, title: impl Into<String>, add_contents: impl FnOnce(&mut Ui)) {
menu_impl(ui, title, Box::new(add_contents))
}
fn menu_impl<'c>(
ui: &mut Ui,
title: impl Into<String>,
add_contents: Box<dyn FnOnce(&mut Ui) + 'c>,
) {
let title = title.into();
let bar_id = ui.id();
let menu_id = Id::new(&title);

8
emigui/src/containers/window.rs

@ -126,6 +126,14 @@ impl<'open> Window<'open> {
self,
ctx: &Arc<Context>,
add_contents: impl FnOnce(&mut Ui),
) -> Option<InteractInfo> {
self.show_impl(ctx, Box::new(add_contents))
}
fn show_impl<'c>(
self,
ctx: &Arc<Context>,
add_contents: Box<dyn FnOnce(&mut Ui) + 'c>,
) -> Option<InteractInfo> {
let Window {
title_label,

Loading…
Cancel
Save