summaryrefslogtreecommitdiff
path: root/lib/Tie
diff options
context:
space:
mode:
authorUnknown Contributor <data-drift@so.uio.no>1997-01-28 21:14:34 +0100
committerChip Salzenberg <chip@atlantic.net>1997-01-29 18:11:00 +1200
commit77bc640839c0e499bd3e63d55da049db6a98bdad (patch)
treeb725e56904fe0c0fa2b155fb330326221b93749d /lib/Tie
parenta50773103a26cca5998b5148cb57f8efac11a750 (diff)
downloadperl-77bc640839c0e499bd3e63d55da049db6a98bdad.tar.gz
Allow for really big keys in Tie::SubstrHash
private-msgid: <199701282014.VAA12645@selters.uio.no>
Diffstat (limited to 'lib/Tie')
-rw-r--r--lib/Tie/SubstrHash.pm8
1 files 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;