Skip to content

Commit

Permalink
(had more trouble with push) set fields so that callers can inspect t…
Browse files Browse the repository at this point in the history
…he state of the hasher
  • Loading branch information
rsharris committed Jul 22, 2019
1 parent 3edcb49 commit 7511161
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions sabuhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class SabuHash
hF = forward(hF) ^ kernelTable[chIn];
}

hForward = hF;

hF = avalanche(hF);
if (hF == 0) return 1;
else return hF;
Expand All @@ -224,6 +226,8 @@ class SabuHash
hF = forward(hF) ^ kernelTable[chIn];
}

hForward = hF;

hF = avalanche(hF);
if (hF == 0) return 1;
else return hF;
Expand All @@ -246,14 +250,16 @@ class SabuHash
hF = backward(hF ^ forwardByK2[twoBits]);
}

hForward = hF;

hF = avalanche(hF);
if (hF == 0) return 1;
else return hF;
}

inline std::uint64_t rolling_hash
(const unsigned char chIn,
const unsigned char chOut=0)
const unsigned char chOut=0) // this was chIn k characters earlier
{
// note that we return 0 iff we don't yet have k characters

Expand Down Expand Up @@ -493,6 +499,9 @@ class SabuHashCanonical
hR = SabuHash::backward(hR ^ forwardByK_RC[chIn]);
}

hForward = hF;
hRevComp = hR;

std::uint64_t h = SabuHash::avalanche(hF+hR);
if (h == 0) return 1;
else return h;
Expand All @@ -515,6 +524,9 @@ class SabuHashCanonical
hR = SabuHash::backward(hR ^ forwardByK_RC[chIn]);
}

hForward = hF;
hRevComp = hR;

std::uint64_t h = SabuHash::avalanche(hF+hR);
if (h == 0) return 1;
else return h;
Expand All @@ -537,14 +549,17 @@ class SabuHashCanonical
hR = SabuHash::forward(hR) ^ kernelTable2_RC[twoBits];
}

hForward = hF;
hRevComp = hR;

std::uint64_t h = SabuHash::avalanche(hF+hR);
if (h == 0) return 1;
else return h;
}

inline std::uint64_t rolling_hash
(const unsigned char chIn,
const unsigned char chOut=0)
const unsigned char chOut=0) // this was chIn k characters earlier
{
// note that we return 0 iff we don't yet have k characters

Expand Down

0 comments on commit 7511161

Please sign in to comment.