Skip to content

Commit

Permalink
Reuse block_qargs for each block
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Zou <87874865+henryzou50@users.noreply.github.com>
  • Loading branch information
mtreinish and henryzou50 committed Nov 5, 2024
1 parent 223bf2e commit b6071ee
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/accelerate/src/consolidate_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ pub(crate) fn consolidate_blocks(
});
let mut all_block_gates: HashSet<NodeIndex> =
HashSet::with_capacity(blocks.iter().map(|x| x.len()).sum());
let mut block_qargs: HashSet<Qubit> = 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();
Expand All @@ -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<Qubit> = HashSet::with_capacity(2);
for node in &block {
let inst = dag.dag()[*node].unwrap_operation();
block_qargs.extend(dag.get_qargs(inst.qubits));
Expand Down

0 comments on commit b6071ee

Please sign in to comment.