From: Unknown Contributor Date: Tue, 28 Jan 1997 20:14:34 +0000 (+0100) Subject: Allow for really big keys in Tie::SubstrHash X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=77bc640839c0e499bd3e63d55da049db6a98bdad;p=p5sagit%2Fp5-mst-13.2.git Allow for really big keys in Tie::SubstrHash private-msgid: <199701282014.VAA12645@selters.uio.no> --- diff --git a/lib/Tie/SubstrHash.pm b/lib/Tie/SubstrHash.pm index 825f305..44c2140 100644 --- a/lib/Tie/SubstrHash.pm +++ b/lib/Tie/SubstrHash.pm @@ -144,13 +144,17 @@ sub hashkey { $hash = 2; for (unpack('C*', $key)) { $hash = $hash * 33 + $_; + &_hashwrap if $hash >= 1e13; } - $hash = $hash - int($hash / $tsize) * $tsize - if $hash >= $tsize; + &_hashwrap if $hash >= $tsize; $hash = 1 unless $hash; $hashbase = $hash; } +sub _hashwrap { + $hash -= int($hash / $tsize) * $tsize; +} + sub rehash { $hash += $hashbase; $hash -= $tsize if $hash >= $tsize;