From 01b47a2ec72f32a19a5e9708889115ef74c2b90c Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Fri, 5 Nov 2021 11:59:25 +0000 Subject: [PATCH] Add inline directives to ensure unit placeholders are optimised away --- compiler/gen_wasm/src/wasm_module/sections.rs | 2 ++ compiler/gen_wasm/src/wasm_module/serialize.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/compiler/gen_wasm/src/wasm_module/sections.rs b/compiler/gen_wasm/src/wasm_module/sections.rs index da43361ed1..46c07d888e 100644 --- a/compiler/gen_wasm/src/wasm_module/sections.rs +++ b/compiler/gen_wasm/src/wasm_module/sections.rs @@ -578,6 +578,7 @@ struct SectionCounter { impl SectionCounter { /// Update the section counter if buffer size increased since last call + #[inline] fn update(&mut self, buffer: &mut SB) { let new_size = buffer.size(); if new_size > self.buffer_size { @@ -586,6 +587,7 @@ impl SectionCounter { } } + #[inline] fn serialize_and_count( &mut self, buffer: &mut SB, diff --git a/compiler/gen_wasm/src/wasm_module/serialize.rs b/compiler/gen_wasm/src/wasm_module/serialize.rs index 2f051553db..9445d8c30b 100644 --- a/compiler/gen_wasm/src/wasm_module/serialize.rs +++ b/compiler/gen_wasm/src/wasm_module/serialize.rs @@ -27,6 +27,7 @@ impl Serialize for u32 { // Unit is used as a placeholder in parts of the Wasm spec we don't use yet impl Serialize for () { + #[inline(always)] fn serialize(&self, _buffer: &mut T) {} }