mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-08 02:08:22 -10:00
intl: pack the US string table via multi-include expansion
The US message table was the last pointer-array consumer in the msg_hash system: 4083 string pointers costing 33KB of relocated data and the bulk of the translation unit's 6137 relocations. The hand-maintained MSG_HASH rows now expand three times - into exactly-sized members of a packed blob struct named by the id token (so mutually exclusive guarded duplicates remain legal), into its initializer, and into the existing id array - producing the same contiguous NUL-walked layout the generated translation headers use, while the file stays freely hand-editable and h2json continues to parse it unchanged for Crowdin source uploads. The label strtab keeps its pointer array: msg_hash_lbl.h holds eight rows and conversion would cost more than it saves. Validation: full lookup output byte-identical to the pointer-array build; strict-C89 overlength, pedantic and Darwin-simulation lanes clean; settings dump byte-identical against a same-tree stash baseline; object size and relocation counts reported by the build.
This commit is contained in:
1 parent
b2610c8264
commit
31f3a60641
1 file changed
+17
-3
+17
-3
@@ -578,9 +578,23 @@ static const char *menu_hash_to_str_us_label_enum(enum msg_hash_enums msg)
|
||||
#endif
|
||||
|
||||
#if defined(MSG_HASH_HAVE_STRTAB)
|
||||
/* The hand-maintained MSG_HASH rows are expanded three times: once
|
||||
* into exactly-sized members of a packed blob struct (named by the
|
||||
* id token, so mutually exclusive guarded duplicates stay legal),
|
||||
* once into its initializer, and once into the id array. This
|
||||
* keeps the file freely hand-editable and h2json-parseable while
|
||||
* eliminating the string pointer array and its relocations, the
|
||||
* same layout the generated translation headers use. */
|
||||
#undef MSG_HASH
|
||||
#define MSG_HASH(Id, str) char m_##Id[sizeof(str)];
|
||||
static const struct msg_hash_us_blob_s
|
||||
{
|
||||
#include "msg_hash_us.h"
|
||||
}
|
||||
#undef MSG_HASH
|
||||
#define MSG_HASH(Id, str) str,
|
||||
static const char *const msg_hash_us_strs[] = {
|
||||
msg_hash_us_blob =
|
||||
{
|
||||
#include "msg_hash_us.h"
|
||||
};
|
||||
#undef MSG_HASH
|
||||
@@ -592,9 +606,9 @@ static const uint32_t msg_hash_us_ids[] = {
|
||||
#define MSG_HASH(Id, str) case Id: return str;
|
||||
|
||||
static const msg_hash_strtab_t msg_hash_us_strtab =
|
||||
{ msg_hash_us_ids, msg_hash_us_strs,
|
||||
{ msg_hash_us_ids, NULL,
|
||||
(uint32_t)(sizeof(msg_hash_us_ids) / sizeof(msg_hash_us_ids[0])),
|
||||
NULL };
|
||||
(const char*)&msg_hash_us_blob };
|
||||
|
||||
static msg_hash_strtab_index_t msg_hash_us_index;
|
||||
|
||||
|
||||
Reference in new issue
Block a user