Refactor the optimisation for immediately-returned Let statements

The original intention was to avoid creating a local when we define
and immediately return a primitive value. But now our default path
does avoids unnecessary locals anyway!

For StackMemory values we do need an optimised path but it's nicer
to just pass a flag to Storage::allocate.
This commit is contained in:
Brian Carroll 2021-10-18 13:18:10 +02:00
parent 2daefc8b32
commit 1b97675f1f
3 changed files with 37 additions and 54 deletions

View file

@ -133,7 +133,10 @@ pub struct CopyMemoryConfig {
}
pub fn copy_memory(code_builder: &mut CodeBuilder, config: CopyMemoryConfig) {
debug_assert!(config.from_ptr != config.to_ptr || config.from_offset != config.to_offset);
if config.from_ptr == config.to_ptr && config.from_offset == config.to_offset {
return;
}
let alignment_flag = encode_alignment(config.alignment_bytes);
let mut i = 0;
while config.size - i >= 8 {