[Fontconfig] 2.4 branch fc-cache

Patrick Lam plam at MIT.EDU
Wed Sep 14 12:55:31 EST 2005


James Cloos wrote:
> fc-cache isn't creating fonts.cache-2 files in directories w/ only
> sub directories and no font files.
> 
> In src/fccache.c::FcDirCacheWrite() there is this:
> 
>     current_dir_block = FcDirCacheProduce (set, &metadata);
> 
>     if (!metadata.count)
>     {
>         unlink ((char *)cache_file);
>         free (cache_file);
>         return FcTrue;
>     }
> 
> well before we get to:
> 
>     for (i = 0; i < dirs->size; i++)
>         FcCacheWriteString (fd, (char *)dirs->strs[i]);
>     FcCacheWriteString (fd, "");
> 
> 
> The unlink() call should probably either be conditioned on
> metadata.count NOR dirs->size or there should be a nested if
> to write out a directories-only cache-2 file if there are no
> font files in that dir, yes?
> 
> It does seem unlikely that readdir(2) followed by n stat(2) calls
> is a win over a list of the sub dirs.

I thought about this issue when implementing the directory caches.  At
the time, it didn't seem like it'd be such a big deal to not cache
directories, because there would be relatively few of them, especially
in directories with no font files.  However, this may not be the case.

I'd like to ask about how many directories people encounter; if n is,
like, 20, then the current state might be ok, but if people do have
n=1000, then I'll certainly fix this.

pat



More information about the Fontconfig mailing list