Skip to content

Commit

Permalink
Speedup bytecode-gen by applying an upper bound on read_exact (Fuel…
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadfawaz authored Oct 22, 2022
1 parent aaf7c88 commit 9418b83
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sway-core/src/asm_generation/finalized_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ fn to_bytecode_mut(
if let Some(span) = &span {
source_map.insert(half_word_ix, span);
}
op.read_exact(&mut buf[half_word_ix * 4..])
let read_range_upper_bound =
core::cmp::min(half_word_ix * 4 + std::mem::size_of_val(&op), buf.len());
op.read_exact(&mut buf[half_word_ix * 4..read_range_upper_bound])
.expect("Failed to write to in-memory buffer.");
half_word_ix += 1;
}
Expand Down

0 comments on commit 9418b83

Please sign in to comment.