Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2a73164

Browse files
committed
Improve set of candidate multipliers for perfect hash function generation
The previous set of multipliers was not adapted for large sets of short keys, and this new set of multipliers allows to generate perfect hash functions for larger sets without having an impact for existing callers of those functions, as experimentation has showed. A future commit will make use of that to improve the performance of unicode normalization. All multipliers compile to shift-and-add instructions on most platforms. This has been tested as far back as gcc 4.1 and clang 3.8. Author: John Naylor Reviewed-by: Mark Dilger, Michael Paquier Discussion: https://postgr.es/m/CACPNZCt4fbJ0_bGrN5QPt34N4whv=mszM0LMVQdoa2rC9UMRXA@mail.gmail.com
1 parent 9868167 commit 2a73164

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/tools/PerfectHash.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ sub generate_hash_function
8181
# to calculate via shift-and-add, so don't change them without care.
8282
# (Commonly, random seeds are tried, but we want reproducible results
8383
# from this program so we don't do that.)
84-
my $hash_mult1 = 31;
84+
my $hash_mult1 = 257;
8585
my $hash_mult2;
8686
my $hash_seed1;
8787
my $hash_seed2;
8888
my @subresult;
8989
FIND_PARAMS:
90-
foreach (127, 257, 521, 1033, 2053)
90+
foreach (17, 31, 127, 8191)
9191
{
9292
$hash_mult2 = $_; # "foreach $hash_mult2" doesn't work
9393
for ($hash_seed1 = 0; $hash_seed1 < 10; $hash_seed1++)

0 commit comments

Comments
 (0)