stas 2003/11/04 10:29:02
Modified: t/response/TestPerl hash_attack.pm Log: a few tweaks Revision Changes Path 1.4 +4 -5 modperl-2.0/t/response/TestPerl/hash_attack.pm Index: hash_attack.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestPerl/hash_attack.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -u -r1.3 -r1.4 --- hash_attack.pm 4 Nov 2003 18:22:53 -0000 1.3 +++ hash_attack.pm 4 Nov 2003 18:29:02 -0000 1.4 @@ -114,10 +114,9 @@ # integer'). So we outsmart Perl and take modules 2*32 after each # calculation, emulating overflows that happen in C. sub hash { - my ($s) = @_; - my ($u, @c); - @c = split //, $s; - $u = 0; + my $s = shift; + my @c = split //, $s; + my $u = HASH_SEED; for (@c) { # (A % M) + (B % M) == (A + B) % M # This works because '+' produces a NV, which is big enough to hold @@ -138,7 +137,7 @@ sub hash_original { my $s = shift; my @c = split //, $s; - my $u = 0; + my $u = HASH_SEED; for (@c) { $u += ord; $u %= MASK_U32; $u += $u << 10; $u %= MASK_U32;