Skip to content

Commit

Permalink
Remove dependency on lazy_static
Browse files Browse the repository at this point in the history
For a hashset of only 6 elements that is only checked once, there's not
really any point to pull in an extra dependency or use a hash set at
all.
  • Loading branch information
jakelishman committed Apr 12, 2023
1 parent bdd373e commit 5f74f1e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 24 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/qasm2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ crate-type = ["cdylib"]

[dependencies]
hashbrown = "0.13.2"
lazy_static = "1.4"
pyo3 = { version = "0.18.1", features = ["extension-module"] }
3 changes: 0 additions & 3 deletions crates/qasm2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
// copyright notice, and modified files need to carry a notice indicating
// that they have been altered from the originals.

#[macro_use]
extern crate lazy_static;

use pyo3::prelude::*;
use pyo3::Python;

Expand Down
15 changes: 2 additions & 13 deletions crates/qasm2/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,7 @@ const QELIB1: [(&str, usize, usize); 23] = [
("cu3", 3, 2),
];

lazy_static! {
static ref BUILTIN_CLASSICAL: HashSet<&'static str> = {
let mut out = HashSet::with_capacity(6);
out.insert("cos");
out.insert("exp");
out.insert("ln");
out.insert("sin");
out.insert("sqrt");
out.insert("tan");
out
};
}
const BUILTIN_CLASSICAL: [&str; 6] = ["cos", "exp", "ln", "sin", "sqrt", "tan"];

/// Define a simple newtype that just has a single non-public `usize` field, has a `new`
/// constructor, and implements `Copy` and `IntoPy`. The first argument is the name of the type,
Expand Down Expand Up @@ -316,7 +305,7 @@ impl State {
state.define_gate(None, "U".to_owned(), 3, 1)?;
state.define_gate(None, "CX".to_owned(), 0, 2)?;
for classical in custom_classical {
if BUILTIN_CLASSICAL.contains(&*classical.name) {
if BUILTIN_CLASSICAL.contains(&&*classical.name) {
return Err(QASM2ParseError::new_err(message_generic(
None,
&format!(
Expand Down

0 comments on commit 5f74f1e

Please sign in to comment.