mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
Wasm: Simplify CodeBuilder serialization, based on Richard's suggestion
This commit is contained in:
parent
54e820620a
commit
e37ca971bd
1 changed files with 6 additions and 19 deletions
|
@ -499,26 +499,13 @@ impl<'a> CodeBuilder<'a> {
|
|||
buffer.append_slice(&self.preamble);
|
||||
|
||||
let mut code_pos = 0;
|
||||
let mut insert_iter = self.insertions.iter();
|
||||
loop {
|
||||
let next_insert = insert_iter.next();
|
||||
let next_pos = match next_insert {
|
||||
Some(Insertion { at, .. }) => *at,
|
||||
None => self.code.len(),
|
||||
};
|
||||
|
||||
buffer.append_slice(&self.code[code_pos..next_pos]);
|
||||
|
||||
match next_insert {
|
||||
Some(Insertion { at, start, end }) => {
|
||||
buffer.append_slice(&self.insert_bytes[*start..*end]);
|
||||
code_pos = *at;
|
||||
}
|
||||
None => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for Insertion { at, start, end } in self.insertions.iter() {
|
||||
buffer.append_slice(&self.code[code_pos..(*at)]);
|
||||
buffer.append_slice(&self.insert_bytes[*start..*end]);
|
||||
code_pos = *at;
|
||||
}
|
||||
|
||||
buffer.append_slice(&self.code[code_pos..self.code.len()]);
|
||||
}
|
||||
|
||||
/// Serialize all byte vectors in the right order
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue