Weird bucket choice or number in cCharSetFreezeOrig() and FcCharSetFindFrozen()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi again,

There is another thing that looks odd to me in src/fccharset.c:

#define FC_CHAR_SET_HASH_SIZE    67

[...]

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];

[...]

static const FcCharSet *
FcCharSetFindFrozen (FcCharSetFreezer *freezer, const FcCharSet *orig)
{
    FcCharSetOrigEnt    **bucket = &freezer->orig_hash_table[((uintptr_t) orig) & FC_CHAR_SET_HASH_SIZE];

[...]

I seems to me that either FC_CHAR_SET_HASH_SIZE should be defined as a
power of two minus one (2**n - 1 for some n), or the two occurrences of
the & operator in the above lines should be replaced with a % operator.
Otherwise, at most 8 buckets among the 67 available in
freezer->orig_hash_table can effectively be used
(67 = 64 + 2 + 1 and 2**3 = 8).

What do you think?

(all this with current 'master', i.e.
fontconfig commit 28139816d62b8444ca61a000a87c71e59fef104d)

Regards

-- 
Florent
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/fontconfig




[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux