Skip to content

Commit

Permalink
mark roll_hash functions as inline
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Oct 15, 2024
1 parent d8d06f5 commit ff6c2d3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rollhash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const _: () = assert!(
const _: () = assert!(is_prime(PRIME as u64), "PRIME must be a prime number");
const _: () = assert!(is_prime(MODULUS as u64), "MODULUS must be a prime number");


#[inline(always)]
pub fn roll_hash(old: i64, new: u8) -> i64 {
(((old * PRIME) % MODULUS) + (new as i64)) % MODULUS
}
Expand All @@ -30,6 +30,7 @@ fn roll_hash_back(old: i64, new: u8) -> i64 {
((((old + MODULUS) - (new as i64)) % MODULUS) * PRIME_INVERSE) % MODULUS
}

#[inline(always)]
pub fn roll_hash_slice(slice: &[u8]) -> i64 {
let mut hash = 0;
for &byte in slice {
Expand Down

0 comments on commit ff6c2d3

Please sign in to comment.