Add inline directives to ensure unit placeholders are optimised away

This commit is contained in:
Brian Carroll 2021-11-05 11:59:25 +00:00
parent d220ed7a23
commit 01b47a2ec7
2 changed files with 3 additions and 0 deletions

View file

@ -578,6 +578,7 @@ struct SectionCounter {
impl SectionCounter {
/// Update the section counter if buffer size increased since last call
#[inline]
fn update<SB: SerialBuffer>(&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<SB: SerialBuffer, S: Serialize>(
&mut self,
buffer: &mut SB,

View file

@ -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<T: SerialBuffer>(&self, _buffer: &mut T) {}
}