Generate OP_IS_SOCKET() and OP_IS_FILETEST() macros
[p5sagit/p5-mst-13.2.git] / lib / Tie / SubstrHash.pm
index 825f305..4b18a58 100644 (file)
@@ -69,7 +69,7 @@ sub FETCH {
 sub STORE {
     local($self,$key,$val) = @_;
     local($klen, $vlen, $tsize, $rlen) = @$self[1..4];
-    croak("Table is full") if $self[5] == $tsize;
+    croak("Table is full") if $$self[5] == $tsize;
     croak(qq/Value "$val" is not $vlen characters long./)
        if length($val) != $vlen;
     my $writeoffset;
@@ -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;