Skip to content

Commit

Permalink
Only generate array when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
jlapeyre committed Jun 6, 2024
1 parent c4adde0 commit 0bce4d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/circuit/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ pub fn populate_std_gate_map(py: Python, rs_gate: StandardGate, py_gate: PyObjec

#[inline]
pub fn get_std_gate_class(py: Python, rs_gate: StandardGate) -> PyResult<PyObject> {
let array: [Option<PyObject>; STANDARD_GATE_SIZE] = core::array::from_fn(|_| None);
let gate_map = unsafe { STDGATE_PYTHON_GATES.get_or_init(py, || array) };
let gate_map =
unsafe { STDGATE_PYTHON_GATES.get_or_init(py, || core::array::from_fn(|_| None)) };
let gate = &gate_map[rs_gate as usize];
let populate = gate.is_none();
let out_gate = match gate {
Expand Down

0 comments on commit 0bce4d4

Please sign in to comment.