[Fontconfig] Fontconfig performance question.

Krzysztof Dabrowski fontconfig@fontconfig.org
Thu, 8 May 2003 14:00:25 +0200


Dnia =C5=9Broda 07 maj 2003 06:28 pm, Keith Packard napisa=C5=82:
> Around 11 o'clock on May 7, Krzysztof Dabrowski wrote:
> > FcNameParse who is responsible for 22.84% of total execution time..
>
> I'm interested in getting a replacement file structure for the current
> fonts.cache-1 files; those are now text files and parsing that is just too
> slow.
>
> Because the files are versioned, we really can completely redesign the
> format.

I'm thinking about something more radical:

I thought about serialising this struct to disk:

struct _FcConfig {
    FcStrSet    *configDirs;        /* directories to scan for fonts */
    FcChar8     *cache;             /* name of per-user cache file */
    FcBlanks    *blanks;
    FcStrSet    *fontDirs;
    FcStrSet    *configFiles;       /* config files loaded */
    FcSubst     *substPattern;      /* substitutions for patterns */
    FcSubst     *substFont;         /* substitutions for fonts */
    int         maxObjects;         /* maximum number of tests in all subst=
s   =20
    FcFontSet   *fonts[FcSetApplication + 1];
    time_t      rescanTime;         /* last time information was scanned */
    int         rescanInterval;     /* interval between scans */
};

I'm more into Java programming these days and my C is a little rusty, so th=
e=20
question is: are there any automatic way to serialise a struct in C (or may=
be=20
a helper library exists)? If not then it should still be possible to dump i=
t=20
wholesale somehow.

And since font configuration rarely changes, then it could be loaded only o=
ne,=20
then saved to disk for other applications to use and have a reasonable TTL =
(a=20
day/week/whatever).

What do you think about it? If you could suggest me a right way of serialis=
ing=20
it to disk then i could even try to program it in my spare time if i can=20
manage to find any.

Kris