From 757dfad9009e0158c4283433a9764b345a9dd12f Mon Sep 17 00:00:00 2001 From: Chuck Crayne Date: Sun, 2 Sep 2007 01:00:34 +0000 Subject: Force use of integer values for generating hash keys. --- perllib/phash.ph | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/perllib/phash.ph b/perllib/phash.ph index 679dc4f..4339d58 100644 --- a/perllib/phash.ph +++ b/perllib/phash.ph @@ -13,6 +13,7 @@ require 'random_sv_vectors.ph'; # 32-bit rotate # sub rot($$) { + use integer; my($v,$s) = @_; return (($v << $s)+($v >> (32-$s))) & 0xffffffff; @@ -24,6 +25,7 @@ sub rot($$) { # prehash(key, sv, N) # sub prehash($$$) { + use integer; my($key, $n, $sv) = @_; my $c; my $k1 = 0, $k2 = 0; @@ -37,8 +39,8 @@ sub prehash($$$) { } # Create a bipartite graph... - $k1 = (($k1 % $n) << 1) + 0; - $k2 = (($k2 % $n) << 1) + 1; + $k1 = (($k1 & ($n-1)) << 1) + 0; + $k2 = (($k2 & ($n-1)) << 1) + 1; return ($k1, $k2); } -- cgit v1.2.3