diff options
author | Keith Packard <keithp@koto.keithp.com> | 2007-10-18 09:43:22 -0700 |
---|---|---|
committer | Keith Packard <keithp@koto.keithp.com> | 2007-10-18 09:43:22 -0700 |
commit | 96925b99c0551c4ed6bf7099473d0d36964f52cd (patch) | |
tree | b4ce254f6e1e25b61e865c0fd8b9c64f867471d3 /fc-glyphname | |
parent | bc5e8adb4d05d1d03007951f46aaacc63c3b2197 (diff) |
Eliminate relocations for glyph name table.
Glyph names (now used only for dingbats) were using many relocations,
causing startup latency plus per-process memory usage. Replace pointers with
table indices, shrinking table size and elimninating relocations.
Diffstat (limited to 'fc-glyphname')
-rw-r--r-- | fc-glyphname/fc-glyphname.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/fc-glyphname/fc-glyphname.c b/fc-glyphname/fc-glyphname.c index d4d0b990..b63ed24a 100644 --- a/fc-glyphname/fc-glyphname.c +++ b/fc-glyphname/fc-glyphname.c @@ -217,15 +217,15 @@ insert (FcGlyphName *gn, FcGlyphName **table, FcChar32 h) static void dump (FcGlyphName * const *table, const char *name) { - int i; + int i; - printf ("static const FcGlyphName *%s[%d] = {\n", name, hash); + printf ("static const FcGlyphId %s[%d] = {\n", name, hash); for (i = 0; i < hash; i++) if (table[i]) - printf ("(FcGlyphName *) &glyph%d,\n", rawindex(table[i])); + printf (" %d,\n", rawindex(table[i])); else - printf ("0,\n"); + printf (" -1,\n"); printf ("};\n"); } @@ -237,6 +237,7 @@ main (int argc, char **argv) char line[1024]; FILE *f; int i; + char *type; i = 0; while (argv[i+1]) @@ -283,16 +284,27 @@ main (int argc, char **argv) printf ("#define FC_GLYPHNAME_HASH %u\n", hash); printf ("#define FC_GLYPHNAME_REHASH %u\n", rehash); printf ("#define FC_GLYPHNAME_MAXLEN %d\n\n", max_name_len); + if (nraw < 128) + type = "int8_t"; + else if (nraw < 32768) + type = "int16_t"; + else + type = "int32_t"; + + printf ("typedef %s FcGlyphId;\n\n", type); /* * Dump out entries */ + printf ("static const struct { const FcChar32 ucs; const FcChar8 name[%d]; } glyphs[%d] = {\n", + max_name_len + 1, nraw); + for (i = 0; i < nraw; i++) - printf ("static const struct { const FcChar32 ucs; const FcChar8 name[%d]; }" - " glyph%d = { 0x%lx, \"%s\" };\n", - (int) strlen ((char *) raw[i]->name) + 1, - i, (unsigned long) raw[i]->ucs, raw[i]->name); + printf (" { 0x%lx, \"%s\" },\n", + (unsigned long) raw[i]->ucs, raw[i]->name); + + printf ("};\n"); /* * Dump out name_to_ucs table |