hugomrdias / rabin-wasm

Rabin fingerprinting implemented in WASM
28 stars 7 forks source link

Question about implementation #9

Closed MaxGraey closed 4 years ago

MaxGraey commented 4 years ago

I'm just wondering why you changed to used before:

export function mod(x: u64,  p: u64): u64 {
  while (degree(x) >= degree(p)) {
      var shift = degree(x) - degree(p);
      x = x ^ (p << shift);
  }
  return x;
}

instead more efficient version?

export function mod(x: u64, p: u64): u64 {
  let shift: i32;
  let dp = degree(p);
  while ((shift = degree(x) - dp) >= 0) {
    x ^= p << shift;
  }
  return x;
}

Is it some security reasons?

hugomrdias commented 4 years ago

i needed to revert your changes because the output was not right and i wanted to publish a new release fast, so basically i tried to port only clearly "safe" parts from your PR. This looks completely fine, i have a todo to review your PR again and port everything, your PR is faster than the current release and i want to get that speed back but i need time to make sure the output is right.

hugomrdias commented 4 years ago

thank you btw your help was awesome 🥇

MaxGraey commented 4 years ago

Got it! Ok, feel free to ask any help or questions about further perf tuning.