From fa01b957e12edd9c939ae32d859f8f530f4ad84f Mon Sep 17 00:00:00 2001 From: Fibonacci747 Date: Mon, 16 Feb 2026 08:56:23 +0100 Subject: [PATCH] =?UTF-8?q?perf:=20cache=20successor=20params=20to=20avoid?= =?UTF-8?q?=20O(P=C3=97A)=20cloning=20in=20arg=20demotion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sway-ir/src/optimize/arg_demotion.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sway-ir/src/optimize/arg_demotion.rs b/sway-ir/src/optimize/arg_demotion.rs index 1b67c16e1ca..ac97fce9b9d 100644 --- a/sway-ir/src/optimize/arg_demotion.rs +++ b/sway-ir/src/optimize/arg_demotion.rs @@ -280,9 +280,10 @@ fn demote_block_signature(context: &mut Context, function: &Function, block: Blo let preds = block.pred_iter(context).copied().collect::>(); for pred in preds { + let params = pred.get_succ_params(context, &block); for (arg_idx, _arg_val, arg_var) in &arg_vars { // Get the value which is being passed to the block at this index. - let arg_val = pred.get_succ_params(context, &block)[*arg_idx]; + let arg_val = params[*arg_idx]; // Insert a `get_local` and `store` for each candidate argument and insert them at the // end of this block, before the terminator.