]> git.wh0rd.org - fontconfig.git/commitdiff
Make cache reference counting more efficient.
authorKeith Packard <keithp@neko.keithp.com>
Tue, 5 Sep 2006 05:26:24 +0000 (22:26 -0700)
committerKeith Packard <keithp@neko.keithp.com>
Tue, 5 Sep 2006 05:26:24 +0000 (22:26 -0700)
Eliminate need to reference cache object once per cached font, instead
just count the number of fonts used from the cache and bump the reference
count once by that amount. I think this makes this refernece technique
efficient enough for use.

src/fccache.c
src/fccfg.c
src/fcint.h

index 69a29f2e94658c627c2417cc63d108352275e30e..77a303d77a044e59bedb6a3ba70e0e030115aca5 100644 (file)
@@ -476,6 +476,15 @@ FcDirCacheMapFd (int fd, struct stat *fd_stat)
     return cache;
 }
 
+void
+FcDirCacheReference (FcCache *cache, int nref)
+{
+    FcCacheSkip *skip = FcCacheFindByAddr (cache);
+
+    if (skip)
+       skip->ref += nref;
+}
+
 void
 FcDirCacheUnload (FcCache *cache)
 {
index 1139744c04ec5f7dc01c82e810076601c93277fd..d9502f0d341f691deaa5b3c1825f6924bb1908f5 100644 (file)
@@ -239,6 +239,8 @@ FcConfigAddCache (FcConfig *config, FcCache *cache)
     fs = FcCacheSet (cache);
     if (fs)
     {
+       int     nref = 0;
+       
        for (i = 0; i < fs->nfont; i++)
        {
            FcPattern   *font = FcFontSetFont (fs, i);
@@ -260,9 +262,10 @@ FcConfigAddCache (FcConfig *config, FcCache *cache)
            if (!FcConfigAcceptFont (config, font))
                continue;
                
-           FcPatternReference (font);
+           nref++;
            FcFontSetAdd (config->fonts[FcSetSystem], font);
        }
+       FcDirCacheReference (cache, nref);
     }
 
     /*
index a05421955fd065da4fb93113893e92d2579865e5..7dab169a49378cd9688a2a3f96af6c3876d1da52 100644 (file)
@@ -513,6 +513,9 @@ FcCacheObjectDereference (void *object);
 FcPrivate void
 FcCacheFini (void);
     
+void
+FcDirCacheReference (FcCache *cache, int nref);
+
 /* fccfg.c */
 
 FcPrivate FcBool