Skip to content

Commit

Permalink
use global variable for bits_per_char
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonVandeVyver committed Oct 14, 2024
1 parent c94df8d commit 850b2ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sa-builder/src/bitpacking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn get_rank(c: u8) -> u8 {
}
}

const BITS_PER_CHAR: usize = 5;
pub const BITS_PER_CHAR: usize = 5;
pub fn bitpack_text(text: &Vec<u8>, sparseness_factor: u8) -> Vec<i64> {
let sparseness_factor = sparseness_factor as usize;
let num_ints = (text.len() + (sparseness_factor-1)) / sparseness_factor;
Expand Down
5 changes: 2 additions & 3 deletions sa-builder/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::error::Error;
use crate::bitpacking::bitpack_text;
use crate::bitpacking::BITS_PER_CHAR;
use clap::{Parser, ValueEnum};

pub mod bitpacking;
Expand Down Expand Up @@ -58,10 +59,8 @@ pub fn build_ssa(
// Build the suffix array using the selected algorithm
let mut sa = match construction_algorithm {
SAConstructionAlgorithm::LibSais => {
let bits_per_char = 5;
let sparseness_factor = 4;
let mut packed_text = bitpack_text(text, sparseness_factor);
libsais64_rs::sais64_long(&mut packed_text, 1 << (bits_per_char * sparseness_factor))
libsais64_rs::sais64_long(&mut packed_text, 1 << (BITS_PER_CHAR * sparseness_factor as usize))
},
SAConstructionAlgorithm::LibDivSufSort => libdivsufsort_rs::divsufsort64(text)
}
Expand Down

0 comments on commit 850b2ee

Please sign in to comment.