i crunched the numbers and found out that _glfwKeySym2Unicode in “xkb_unicode.h”, used
when no input method is available, performs a binary search with complexity O(log(n)), given that the keysymtable has up to 828 elements,
where each element occupies 4 bytes (2 short pairs), so 828 x 4 = 3312 bytes, which is redundant…
so if you use this way of binary search, then O(log(828)) = 2.918
you can simply reduce the size down to 2424 bytes of memory if you only take the unicode value in one linear array rather than using a LUT and have a function that calculates the index which will access the table with access O(1)…
the trick is to pad the corresponding unicode values with zeroes of a keysym group for a given ucs…
for example:
static const unsigned short keysymtab[] =
{
///XK_LATIN2 (57 unicode chars + 38 paddings)
// 0x01a1 - 0x01ff
0x0104, 0x02d8, 0x0141, 0x0000, 0x013d, 0x015a, 0x0000, 0x0000,
0x0160, 0x015e, 0x0164, 0x0179, 0x0000, 0x017d, 0x017b, 0x0000,
0x0105, 0x02db, 0x0142, 0x0000, 0x013e, 0x015b, 0x02c7, 0x0000,
0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c, 0x0154,
0x0000, 0x0000, 0x0102, 0x0000, 0x0139, 0x0106, 0x0000, 0x010c,
0x0000, 0x0118, 0x0000, 0x011a, 0x0000, 0x0000, 0x010e, 0x0110,
0x0143, 0x0147, 0x0000, 0x0000, 0x0150, 0x0000, 0x0000, 0x0158,
0x016e, 0x0000, 0x0170, 0x0000, 0x0000, 0x0162, 0x0000, 0x0155,
0x0000, 0x0000, 0x0103, 0x0000, 0x013a, 0x0107, 0x0000, 0x010d,
0x0000, 0x0119, 0x0000, 0x011b, 0x0000, 0x0000, 0x010f, 0x0111,
0x0144, 0x0148, 0x0000, 0x0000, 0x0151, 0x0000, 0x0000, 0x0159,
0x016f, 0x0000, 0x0171, 0x0000, 0x0000, 0x0163, 0x02d9,
. . .
};
you pad it with zeroes so the unicode value is indexed correctly, when the keysym counts up…
this allows you to index the unicode value accordingly…