From b6071eecdd286d2b734d92be21aee79592b47017 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 5 Nov 2024 17:33:18 -0500 Subject: [PATCH] Reuse block_qargs for each block Co-authored-by: Henry Zou <87874865+henryzou50@users.noreply.github.com> --- crates/accelerate/src/consolidate_blocks.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/accelerate/src/consolidate_blocks.rs b/crates/accelerate/src/consolidate_blocks.rs index e8bbc53d523..1edd592ce87 100644 --- a/crates/accelerate/src/consolidate_blocks.rs +++ b/crates/accelerate/src/consolidate_blocks.rs @@ -94,7 +94,9 @@ pub(crate) fn consolidate_blocks( }); let mut all_block_gates: HashSet = HashSet::with_capacity(blocks.iter().map(|x| x.len()).sum()); + let mut block_qargs: HashSet = HashSet::with_capacity(2); for block in blocks { + block_qargs.clear(); if block.len() == 1 { let inst_node = block[0]; let inst = dag.dag()[inst_node].unwrap_operation(); @@ -119,7 +121,6 @@ pub(crate) fn consolidate_blocks( } let mut basis_count: usize = 0; let mut outside_basis = false; - let mut block_qargs: HashSet = HashSet::with_capacity(2); for node in &block { let inst = dag.dag()[*node].unwrap_operation(); block_qargs.extend(dag.get_qargs(inst.qubits));