mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Wasm: tweaks from self-review
This commit is contained in:
parent
c5134fa015
commit
f4137013cb
3 changed files with 17 additions and 13 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue