Skip to content

Commit

Permalink
Fix: Improper use of Entry API.
Browse files Browse the repository at this point in the history
- Use `or_insert_with` instead of `or_insert` to perform actions before inserting a value.
  • Loading branch information
raynelfss committed Sep 6, 2024
1 parent 468869c commit d846cd0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/circuit/src/dag_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6392,7 +6392,7 @@ impl DAGCircuit {
// Check all the qubits in this instruction.
for qubit in self.qargs_interner.get(qubits_id) {
// Retrieve each qubit's last node
let qubit_last_node = *qubit_last_nodes.entry(*qubit).or_insert({
let qubit_last_node = *qubit_last_nodes.entry(*qubit).or_insert_with(|| {
// If the qubit is not in the last nodes collection, the edge between the output node and its predecessor.
// Then, store the predecessor's NodeIndex in the last nodes collection.
let output_node = self.qubit_io_map[qubit.0 as usize][1];
Expand All @@ -6414,7 +6414,7 @@ impl DAGCircuit {

// Check all the clbits in this instruction.
for clbit in all_cbits {
let clbit_last_node = *clbit_last_nodes.entry(clbit).or_insert({
let clbit_last_node = *clbit_last_nodes.entry(clbit).or_insert_with(|| {
// If the qubit is not in the last nodes collection, the edge between the output node and its predecessor.
// Then, store the predecessor's NodeIndex in the last nodes collection.
let output_node = self.clbit_io_map[clbit.0 as usize][1];
Expand Down

0 comments on commit d846cd0

Please sign in to comment.