and then handle the remaining bytes after the loop.
ScanKeywords_hash_func() function would be possible.
If you think this approach is promising, I would be happy to prepare a patch for it,
but I wanted to check with the project this idea has not already been considered and ruled out
(Reding 8 bytes a time instead would perhaps be a win since some keywords are quite long.)
sub _calc_hash
{
my ($key, $mult, $seed) = @_;
my $result = $seed;
my $i=0;
my $keylen = length($key);
for (; $keylen>=4; $keylen-=4, $i+=4) {
my $cn = (ord(substr($key,$i+0,1)) << 0)
| (ord(substr($key,$i+1,1)) << 8)
| (ord(substr($key,$i+2,1)) << 16)
| (ord(substr($key,$i+3,1)) << 24);
$cn |= 0x20202020 if $case_fold;
$result = ($result * $mult + $cn) % 4294967296;
}
my $cn = 0;
if ($keylen == 3) {
$cn = (ord(substr($key,$i+0,1)) << 0)
| (ord(substr($key,$i+1,1)) << 8)
| (ord(substr($key,$i+2,1)) << 16);
$cn |= 0x202020 if $case_fold;
} elsif ($keylen == 2) {
$cn = (ord(substr($key,$i+0,1)) << 0)
| (ord(substr($key,$i+1,1)) << 8);
$cn |= 0x2020 if $case_fold;
} elsif ($keylen == 1) {
$cn = (ord(substr($key,$i+0,1)) << 0);
$cn |= 0x20 if $case_fold;
}
$result = ($result * $mult + $cn) % 4294967296;
return $result;
}