From b938e043ca175a0911598e7f439ed6e200ab6f13 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 31 Aug 2007 18:10:23 +0000 Subject: phash: don't rely on the build platform Perl version of rand() rand() in Perl can vary between platforms, so don't use it. Instead, remove a completely pointless level of indirection (it introduced a permutation which cancelled itself out) and provide a canned set of random numbers for the rest. This guarantees we will always use the same numbers. --- tokhash.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tokhash.pl') diff --git a/tokhash.pl b/tokhash.pl index fb65c2f..37be7b1 100755 --- a/tokhash.pl +++ b/tokhash.pl @@ -119,7 +119,7 @@ if (!defined(@hashinfo)) { # Paranoia... verify_hash_table(\%tokens, \@hashinfo); -($n, $sv, $f1, $f2, $g) = @hashinfo; +($n, $sv, $g) = @hashinfo; $sv2 = $sv+2; die if ($n & ($n-1)); @@ -155,14 +155,14 @@ print "#define UNUSED 16383\n"; print " static const int16_t hash1[$n] = {\n"; for ($i = 0; $i < $n; $i++) { - my $h = ${$g}[${$f1}[$i]]; + my $h = ${$g}[$i*2+0]; print " ", defined($h) ? $h : 'UNUSED', ",\n"; } print " };\n"; print " static const int16_t hash2[$n] = {\n"; for ($i = 0; $i < $n; $i++) { - my $h = ${$g}[${$f2}[$i]]; + my $h = ${$g}[$i*2+1]; print " ", defined($h) ? $h : 'UNUSED', ",\n"; } print " };\n"; -- cgit v1.2.3