Skip to content

Commit

Permalink
chore: Replace lazy static (#219)
Browse files Browse the repository at this point in the history
* chore: replace lazy_static with LazyLock from std, generate lookup tables at build time

* remove unused code

*bump MRSV to 1.80
  • Loading branch information
tedil authored Jan 7, 2025
1 parent 44ab9d1 commit ca07ce4
Show file tree
Hide file tree
Showing 6 changed files with 1,411 additions and 760 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "Port of biocommons/hgvs to Rust"
license = "Apache-2.0"
repository = "https://github.com/varfish-org/hgvs-rs"
readme = "README.md"
rust-version = "1.64.0"
rust-version = "1.80.0"

[lib]
name = "hgvs"
Expand All @@ -19,7 +19,6 @@ bio = "2.0"
chrono = "0.4"
enum-map = "2.4"
flate2 = "1.0"
lazy_static = "1.4"
log = "0.4"
md-5 = "0.10"
nom = "7.1"
Expand Down
21 changes: 10 additions & 11 deletions benches/translate_cds.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
use criterion::{criterion_group, criterion_main, Criterion};
use hgvs::sequences::{translate_cds, TranslationTable};
use std::sync::LazyLock;

/// TTN FASTA string from https://www.ncbi.nlm.nih.gov/nuccore/NM_001126114.1
static TTN_FASTA: &str = include_str!("TTN.fasta");

lazy_static::lazy_static! {
/// Raw TTN sequence.
static ref SEQ_TTN: String = {
let mut seq = String::new();
for line in TTN_FASTA.lines() {
if !line.starts_with('>') {
seq.push_str(line);
}
/// Raw TTN sequence.
static SEQ_TTN: LazyLock<String> = LazyLock::new(|| {
let mut seq = String::new();
for line in TTN_FASTA.lines() {
if !line.starts_with('>') {
seq.push_str(line);
}
seq
};
}
}
seq
});

fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("translate_cds TTN", |b| {
Expand Down
Loading

0 comments on commit ca07ce4

Please # to comment.