|
|
077c9d |
commit ac64195ccd4f320659fd0058bc7524c6fd0b37b4
|
|
|
077c9d |
Author: DJ Delorie <dj@redhat.com>
|
|
|
077c9d |
Date: Wed Mar 20 23:56:59 2019 -0400
|
|
|
077c9d |
|
|
|
077c9d |
iconv, localedef: avoid floating point rounding differences [BZ #24372]
|
|
|
077c9d |
|
|
|
077c9d |
Two cases of "int * 1.4" may result in imprecise results, which
|
|
|
077c9d |
in at least one case resulted in i686 and x86-64 producing
|
|
|
077c9d |
different locale files. This replaced that floating point multiply
|
|
|
077c9d |
with integer operations. While the hash table margin is increased
|
|
|
077c9d |
from 40% to 50%, testing shows only 2% increase in overall size
|
|
|
077c9d |
of the locale archive.
|
|
|
077c9d |
|
|
|
077c9d |
https://bugzilla.redhat.com/show_bug.cgi?id=1311954
|
|
|
077c9d |
|
|
|
077c9d |
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
077c9d |
|
|
|
077c9d |
diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c
|
|
|
077c9d |
index d5e8e714233f78d8..696fc8d31231ca2d 100644
|
|
|
077c9d |
--- a/iconv/iconvconfig.c
|
|
|
077c9d |
+++ b/iconv/iconvconfig.c
|
|
|
077c9d |
@@ -1079,9 +1079,9 @@ write_output (void)
|
|
|
077c9d |
|
|
|
077c9d |
/* Create the hashing table. We know how many strings we have.
|
|
|
077c9d |
Creating a perfect hash table is not reasonable here. Therefore
|
|
|
077c9d |
- we use open hashing and a table size which is the next prime 40%
|
|
|
077c9d |
+ we use open hashing and a table size which is the next prime 50%
|
|
|
077c9d |
larger than the number of strings. */
|
|
|
077c9d |
- hash_size = next_prime (nnames * 1.4);
|
|
|
077c9d |
+ hash_size = next_prime (nnames + nnames >> 1);
|
|
|
077c9d |
hash_table = (struct hash_entry *) xcalloc (hash_size,
|
|
|
077c9d |
sizeof (struct hash_entry));
|
|
|
077c9d |
/* Fill the hash table. */
|
|
|
077c9d |
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
|
|
|
077c9d |
index d2eebcfdbb0677e5..9a1639b999d0e2aa 100644
|
|
|
077c9d |
--- a/locale/programs/ld-collate.c
|
|
|
077c9d |
+++ b/locale/programs/ld-collate.c
|
|
|
077c9d |
@@ -2401,8 +2401,8 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
|
|
|
077c9d |
|
|
|
077c9d |
runp = runp->next;
|
|
|
077c9d |
}
|
|
|
077c9d |
- /* Add 40% and find the next prime number. */
|
|
|
077c9d |
- elem_size = next_prime (elem_size * 1.4);
|
|
|
077c9d |
+ /* Add 50% and find the next prime number. */
|
|
|
077c9d |
+ elem_size = next_prime (elem_size + elem_size >> 1);
|
|
|
077c9d |
|
|
|
077c9d |
/* Allocate the table. Each entry consists of two words: the hash
|
|
|
077c9d |
value and an index in a secondary table which provides the index
|