Skip to content

Commit

Permalink
Fix: Use &SmallVec<_> instead of &Box<_>
Browse files Browse the repository at this point in the history
- Due to a `clippy` warning, switch to dereferencing the `Box` when returning references to parameters in an instruction.
  • Loading branch information
raynelfss committed Feb 10, 2025
1 parent c818a4f commit fa7c9df
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/accelerate/src/unitary_synthesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ fn run_2q_unitary_synthesis(
.collect();
(
inst.op().name().to_string(),
inst.params_raw().cloned().map(|boxed| *boxed),
inst.params_raw().cloned(),
inst_qubits,
)
});
Expand Down
6 changes: 3 additions & 3 deletions crates/circuit/src/circuit_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl CircuitData {
inst.op().py_deepcopy(py, Some(&memo))?,
inst.qubits(),
inst.clbits(),
inst.params_raw().cloned(),
inst.params_raw().cloned().map(|params| params.into()),
inst.extra_attrs().clone(),
));
}
Expand All @@ -310,7 +310,7 @@ impl CircuitData {
inst.op().py_copy(py)?,
inst.qubits(),
inst.clbits(),
inst.params_raw().cloned(),
inst.params_raw().cloned().map(|params| params.into()),
inst.extra_attrs().clone(),
));
}
Expand Down Expand Up @@ -690,7 +690,7 @@ impl CircuitData {
inst.op().clone(),
qubits_id,
clbits_id,
inst.params_raw().cloned(),
inst.params_raw().cloned().map(|params| params.into()),
inst.extra_attrs().clone(),
));
self.track_instruction_parameters(py, new_index)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/circuit/src/converters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub fn dag_to_circuit(
op,
instr.qubits(),
instr.clbits(),
instr.params_raw().cloned(),
instr.params_raw().cloned().map(|params| params.into()),
instr.extra_attrs().clone(),
))
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/circuit/src/dag_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6775,7 +6775,7 @@ impl DAGCircuit {
},
qarg_map[instr.qubits()],
carg_map[instr.clbits()],
instr.params_raw().cloned(),
instr.params_raw().cloned().map(|params| params.into()),
instr.extra_attrs().clone(),
))
}),
Expand Down
4 changes: 2 additions & 2 deletions crates/circuit/src/packed_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,8 @@ impl PackedInstruction {

/// Get a reference of the contained parameters.
#[inline]
pub fn params_raw(&self) -> Option<&Box<SmallVec<[Param; 3]>>> {
self.params.as_ref()
pub fn params_raw(&self) -> Option<&SmallVec<[Param; 3]>> {
self.params.as_deref()
}

/// Get a mutable reference of the contained parameters.
Expand Down

0 comments on commit fa7c9df

Please sign in to comment.