[Fontconfig] fontconfig: Branch 'master'
Akira TAGOH
tagoh at kemper.freedesktop.org
Mon Jun 12 08:03:46 UTC 2017
src/fccharset.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 60e1fe550ae5d945c45a7ad04b46ec78da0309aa
Author: Florent Rougon <f.rougon at free.fr>
Date: Thu Jun 8 16:13:29 2017 +0200
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.
diff --git a/src/fccharset.c b/src/fccharset.c
index 6e69f66..69fbf66 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)
More information about the Fontconfig
mailing list