summaryrefslogtreecommitdiff
path: root/perllib
diff options
context:
space:
mode:
authorChuck Crayne <ccrayne@users.sourceforge.net>2007-09-02 01:00:34 +0000
committerChuck Crayne <ccrayne@users.sourceforge.net>2007-09-02 01:00:34 +0000
commit757dfad9009e0158c4283433a9764b345a9dd12f (patch)
treeb127682473f000df10ea9e85150fbbf7a7db82b0 /perllib
parentb938e043ca175a0911598e7f439ed6e200ab6f13 (diff)
downloadnasm-757dfad9009e0158c4283433a9764b345a9dd12f.tar.gz
nasm-757dfad9009e0158c4283433a9764b345a9dd12f.tar.bz2
nasm-757dfad9009e0158c4283433a9764b345a9dd12f.zip
Force use of integer values for generating hash keys.
Diffstat (limited to 'perllib')
-rw-r--r--perllib/phash.ph6
1 files 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);
}