From 77bc640839c0e499bd3e63d55da049db6a98bdad Mon Sep 17 00:00:00 2001 From: Unknown Contributor Date: Tue, 28 Jan 1997 21:14:34 +0100 Subject: [PATCH] Allow for really big keys in Tie::SubstrHash private-msgid: <199701282014.VAA12645@selters.uio.no> --- lib/Tie/SubstrHash.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Tie/SubstrHash.pm b/lib/Tie/SubstrHash.pm index 825f305714..44c2140c7b 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; -- 2.34.1