From bd08234ca777c0dad8db9b0a5a16e2e4a0e9eefc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Kl=C3=B6tzl?= Date: Mon, 2 Jan 2023 21:15:17 +0000 Subject: [PATCH] perf: mark complement as inline (#510) * mark dna::complement as inline This speeds up computing the complement on a long string by ~2.3x. * mark rna::complement as inline --- src/alphabets/dna.rs | 1 + src/alphabets/rna.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/alphabets/dna.rs b/src/alphabets/dna.rs index e3985c2ff9..827af9627b 100644 --- a/src/alphabets/dna.rs +++ b/src/alphabets/dna.rs @@ -62,6 +62,7 @@ lazy_static! { /// assert_eq!(dna::complement(89), 82); // Y → R /// assert_eq!(dna::complement(115), 115); // s → s /// ``` +#[inline] pub fn complement(a: u8) -> u8 { COMPLEMENT[a as usize] } diff --git a/src/alphabets/rna.rs b/src/alphabets/rna.rs index 9411d187b2..8713b9a368 100644 --- a/src/alphabets/rna.rs +++ b/src/alphabets/rna.rs @@ -62,6 +62,7 @@ lazy_static! { /// assert_eq!(rna::complement(115), 115); // s → s /// assert_eq!(rna::complement(78), 78); // N → N /// ``` +#[inline] pub fn complement(a: u8) -> u8 { COMPLEMENT[a as usize] }