Move prime_for back into map
This was causing problem on systems without visibility when map was used from both libharfbuzz and libharfbuzz-subset. Sigh. https://ci.appveyor.com/project/harfbuzz/harfbuzz/build/1.0.1669/job/dey47nmff0770vp3
This commit is contained in:
parent
a2a1484ef9
commit
0a5952e8dd
@ -105,7 +105,7 @@ struct hb_map_t
|
||||
/* Switch to new, empty, array. */
|
||||
population = occupancy = 0;
|
||||
mask = new_size - 1;
|
||||
prime = _hb_prime_for (power);
|
||||
prime = prime_for (power);
|
||||
items = new_items;
|
||||
|
||||
/* Insert back old items. */
|
||||
@ -198,6 +198,57 @@ struct hb_map_t
|
||||
}
|
||||
return tombstone == INVALID ? i : tombstone;
|
||||
}
|
||||
|
||||
static inline unsigned int prime_for (unsigned int shift)
|
||||
{
|
||||
/* Following comment and table copied from glib. */
|
||||
/* Each table size has an associated prime modulo (the first prime
|
||||
* lower than the table size) used to find the initial bucket. Probing
|
||||
* then works modulo 2^n. The prime modulo is necessary to get a
|
||||
* good distribution with poor hash functions.
|
||||
*/
|
||||
/* Not declaring static to make all kinds of compilers happy... */
|
||||
/*static*/ const unsigned int prime_mod [32] =
|
||||
{
|
||||
1, /* For 1 << 0 */
|
||||
2,
|
||||
3,
|
||||
7,
|
||||
13,
|
||||
31,
|
||||
61,
|
||||
127,
|
||||
251,
|
||||
509,
|
||||
1021,
|
||||
2039,
|
||||
4093,
|
||||
8191,
|
||||
16381,
|
||||
32749,
|
||||
65521, /* For 1 << 16 */
|
||||
131071,
|
||||
262139,
|
||||
524287,
|
||||
1048573,
|
||||
2097143,
|
||||
4194301,
|
||||
8388593,
|
||||
16777213,
|
||||
33554393,
|
||||
67108859,
|
||||
134217689,
|
||||
268435399,
|
||||
536870909,
|
||||
1073741789,
|
||||
2147483647 /* For 1 << 31 */
|
||||
};
|
||||
|
||||
if (unlikely (shift >= ARRAY_LENGTH (prime_mod)))
|
||||
return prime_mod[ARRAY_LENGTH (prime_mod) - 1];
|
||||
|
||||
return prime_mod[shift];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -1232,7 +1232,4 @@ round (double x)
|
||||
#endif
|
||||
|
||||
|
||||
HB_INTERNAL unsigned int _hb_prime_for (unsigned int shift);
|
||||
|
||||
|
||||
#endif /* HB_PRIVATE_HH */
|
||||
|
@ -30,54 +30,3 @@
|
||||
void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
|
||||
/*thread_local*/ void * _hb_CrapPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
|
||||
#endif
|
||||
|
||||
|
||||
/* Following comment and table copied from glib. */
|
||||
/* Each table size has an associated prime modulo (the first prime
|
||||
* lower than the table size) used to find the initial bucket. Probing
|
||||
* then works modulo 2^n. The prime modulo is necessary to get a
|
||||
* good distribution with poor hash functions.
|
||||
*/
|
||||
static const unsigned int prime_mod [] =
|
||||
{
|
||||
1, /* For 1 << 0 */
|
||||
2,
|
||||
3,
|
||||
7,
|
||||
13,
|
||||
31,
|
||||
61,
|
||||
127,
|
||||
251,
|
||||
509,
|
||||
1021,
|
||||
2039,
|
||||
4093,
|
||||
8191,
|
||||
16381,
|
||||
32749,
|
||||
65521, /* For 1 << 16 */
|
||||
131071,
|
||||
262139,
|
||||
524287,
|
||||
1048573,
|
||||
2097143,
|
||||
4194301,
|
||||
8388593,
|
||||
16777213,
|
||||
33554393,
|
||||
67108859,
|
||||
134217689,
|
||||
268435399,
|
||||
536870909,
|
||||
1073741789,
|
||||
2147483647 /* For 1 << 31 */
|
||||
};
|
||||
|
||||
unsigned int _hb_prime_for (unsigned int shift)
|
||||
{
|
||||
if (unlikely (shift >= ARRAY_LENGTH (prime_mod)))
|
||||
return prime_mod[ARRAY_LENGTH (prime_mod) - 1];
|
||||
|
||||
return prime_mod[shift];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user