Skip to content

Commit

Permalink
cleanup reversed stores to make logic clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
bhansconnect committed Nov 20, 2023
1 parent ed88232 commit 8caa03b
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions crates/compiler/mono/src/ir/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1580,26 +1580,16 @@ fn store_list_pattern<'a>(
},
arguments: env.arena.alloc([list_sym, start_sym, rest_len_sym]),
});
stmt = Stmt::Let(*rest_sym, rest_expr, list_layout, env.arena.alloc(stmt));
stmt = Stmt::Let(start_sym, start_expr, usize_layout, env.arena.alloc(stmt));
stmt = Stmt::Let(
rest_len_sym,
rest_len_expr,
usize_layout,
env.arena.alloc(stmt),
);
stmt = Stmt::Let(
list_len_sym,
list_len_expr,
usize_layout,
env.arena.alloc(stmt),
);
stmt = Stmt::Let(
total_dropped_sym,
total_dropped_expr,
usize_layout,
env.arena.alloc(stmt),
);
let needed_stores = [
(total_dropped_sym, total_dropped_expr, usize_layout),
(list_len_sym, list_len_expr, usize_layout),
(rest_len_sym, rest_len_expr, usize_layout),
(start_sym, start_expr, usize_layout),
(*rest_sym, rest_expr, list_layout),
];
for (sym, expr, lay) in needed_stores.into_iter().rev() {
stmt = Stmt::Let(sym, expr, lay, env.arena.alloc(stmt));
}
}

if is_productive {
Expand Down

0 comments on commit 8caa03b

Please sign in to comment.