diff options
author | Florent Rougon <f.rougon@free.fr> | 2017-06-08 16:13:29 +0200 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2017-06-12 17:03:37 +0900 |
commit | 60e1fe550ae5d945c45a7ad04b46ec78da0309aa (patch) | |
tree | 16e2d74a9241a0b11855058580b452b56ce36966 /src | |
parent | 7940ada7a89115455b493e64f961e9c3d2cc5045 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/fccharset.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/fccharset.c b/src/fccharset.c index 6e69f665..69fbf662 100644 --- a/src/fccharset.c +++ b/src/fccharset.c @@ -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) |