FcCharSetFreezeOrig(), FcCharSetFindFrozen(): use all buckets of freezer->orig_hash_table
As written at: https://lists.freedesktop.org/archives/fontconfig/2017-June/005929.html I think FcCharSetFreezeOrig() and FcCharSetFindFrozen() should use the % operator instead of & when computing the bucket index for freezer->orig_hash_table, otherwise at most 8 buckets among the 67 available (FC_CHAR_SET_HASH_SIZE) are used. Another way would be to change FC_CHAR_SET_HASH_SIZE to be of the form 2**n -1 (i.e., a power of two minus one). In such a case, the & and % operators would be equivalent.
This commit is contained in:
parent
7940ada7a8
commit
60e1fe550a
|
@ -1120,7 +1120,7 @@ FcCharSetHash (FcCharSet *fcs)
|
|||
static FcBool
|
||||
FcCharSetFreezeOrig (FcCharSetFreezer *freezer, const FcCharSet *orig, const FcCharSet *frozen)
|
||||
{
|
||||
FcCharSetOrigEnt **bucket = &freezer->orig_hash_table[((uintptr_t) orig) & FC_CHAR_SET_HASH_SIZE];
|
||||
FcCharSetOrigEnt **bucket = &freezer->orig_hash_table[((uintptr_t) orig) % FC_CHAR_SET_HASH_SIZE];
|
||||
FcCharSetOrigEnt *ent;
|
||||
|
||||
ent = malloc (sizeof (FcCharSetOrigEnt));
|
||||
|
@ -1204,7 +1204,7 @@ FcCharSetFreezeBase (FcCharSetFreezer *freezer, FcCharSet *fcs)
|
|||
static const FcCharSet *
|
||||
FcCharSetFindFrozen (FcCharSetFreezer *freezer, const FcCharSet *orig)
|
||||
{
|
||||
FcCharSetOrigEnt **bucket = &freezer->orig_hash_table[((uintptr_t) orig) & FC_CHAR_SET_HASH_SIZE];
|
||||
FcCharSetOrigEnt **bucket = &freezer->orig_hash_table[((uintptr_t) orig) % FC_CHAR_SET_HASH_SIZE];
|
||||
FcCharSetOrigEnt *ent;
|
||||
|
||||
for (ent = *bucket; ent; ent = ent->next)
|
||||
|
|
Loading…
Reference in New Issue