Skip to content

Commit

Permalink
Remove const fn, build lookup arrays directly (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmulvaney authored and luizirber committed Apr 1, 2019
1 parent 81f0c37 commit ad2fddf
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/lib.rs
Expand Up @@ -19,28 +19,25 @@ use crate::result::{ErrorKind, Result};

pub(crate) const MAXIMUM_K_SIZE: usize = u32::max_value() as usize;

const fn h_lookup_table() -> [u64; 256] {
const H_LOOKUP: [u64; 256] = {
let mut lookup = [1; 256];
lookup[b'A' as usize] = 0x3c8b_fbb3_95c6_0474;
lookup[b'C' as usize] = 0x3193_c185_62a0_2b4c;
lookup[b'G' as usize] = 0x2032_3ed0_8257_2324;
lookup[b'T' as usize] = 0x2955_49f5_4be2_4456;
lookup[b'N' as usize] = 0;
lookup
}
};

const fn rc_lookup_table() -> [u64; 256] {
const RC_LOOKUP: [u64; 256] = {
let mut lookup = [1; 256];
lookup[b'A' as usize] = 0x2955_49f5_4be2_4456;
lookup[b'C' as usize] = 0x2032_3ed0_8257_2324;
lookup[b'G' as usize] = 0x3193_c185_62a0_2b4c;
lookup[b'T' as usize] = 0x3c8b_fbb3_95c6_0474;
lookup[b'N' as usize] = 0;
lookup
}

const H_LOOKUP: [u64; 256] = h_lookup_table();
const RC_LOOKUP: [u64; 256] = rc_lookup_table();
};

#[inline(always)]
fn h(c: u8) -> u64 {
Expand Down

0 comments on commit ad2fddf

Please sign in to comment.