Wasm: tweaks from self-review

This commit is contained in:
Brian Carroll 2022-01-14 18:50:52 +00:00
parent c5134fa015
commit f4137013cb
3 changed files with 17 additions and 13 deletions

View file

@ -75,11 +75,7 @@ macro_rules! section_impl {
}
fn size(&self) -> usize {
let id = 1;
let encoded_length = 5;
let encoded_count = 5;
id + encoded_length + encoded_count + self.bytes.len()
section_size(self.get_bytes())
}
}
};
@ -106,6 +102,14 @@ where
}
}
fn section_size(bytes: &[u8]) -> usize {
let id = 1;
let encoded_length = 5;
let encoded_count = 5;
id + encoded_length + encoded_count + bytes.len()
}
fn parse_section<'a>(id: SectionId, module_bytes: &'a [u8], cursor: &mut usize) -> (u32, &'a [u8]) {
if module_bytes[*cursor] != id as u8 {
return (0, &[]);
@ -661,11 +665,7 @@ impl<'a> ExportSection<'a> {
}
pub fn size(&self) -> usize {
let id = 1;
let encoded_length = 5;
let encoded_count = 5;
id + encoded_length + encoded_count + self.bytes.len()
section_size(&self.bytes)
}
pub fn empty(arena: &'a Bump) -> Self {