Skip to content

Commit

Permalink
Accept Option<&str> instead of &Option<String>, etc (Qiskit#12593)
Browse files Browse the repository at this point in the history
* Accept Option<&str> instead of &Option<String>, etc

In a few places, this removes unnecessary object copies.

Accept a wider range of input types, and more idiomatic input types
in a few functions. This affects code added in the gates-in-rust PR.

The great majority of the changes here were obsoleted by Qiskit#12594.
The original commit has been cherry picked on top of main.

* Remove unnecessary as_ref()
  • Loading branch information
jlapeyre committed Jul 3, 2024
1 parent eed8f45 commit a897d70
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions crates/circuit/src/circuit_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,13 +1048,7 @@ impl CircuitData {
Ok(PySet::new_bound(py, self.param_table.uuid_map.values())?.unbind())
}

pub fn pop_param(
&mut self,
py: Python,
uuid: u128,
name: String,
default: PyObject,
) -> PyObject {
pub fn pop_param(&mut self, py: Python, uuid: u128, name: &str, default: PyObject) -> PyObject {
match self.param_table.pop(uuid, name) {
Some(res) => res.into_py(py),
None => default.clone_ref(py),
Expand Down
4 changes: 2 additions & 2 deletions crates/circuit/src/parameter_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ impl ParamTable {
self.uuid_map.clear();
}

pub fn pop(&mut self, key: u128, name: String) -> Option<ParamEntry> {
self.names.remove(&name);
pub fn pop(&mut self, key: u128, name: &str) -> Option<ParamEntry> {
self.names.remove(name);
self.uuid_map.remove(&key);
self.table.remove(&key)
}
Expand Down

0 comments on commit a897d70

Please sign in to comment.