Use string pool for file set symlinks
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 7 Sep 2012 09:55:28 +0000 (12:55 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 7 Sep 2012 10:34:50 +0000 (13:34 +0300)
- Removes the last use of our former simple, stupid and slow caches
- For now, use a per-fi pool for this just like the previous caching
  did. Memory use is slightly increased but its faster than before,
  to reap the full benefits (memory and otherwise) we'll want a
  per-transaction pool for these, to be added later.

lib/rpmfi.c
lib/rpmfi_internal.h

index 83b5f97..4ac85d9 100644 (file)
@@ -278,7 +278,7 @@ const char * rpmfiFLinkIndex(rpmfi fi, int ix)
 
     if (fi != NULL && ix >= 0 && ix < fi->fc) {
        if (fi->flinks != NULL)
-           flink = strcacheGet(fi->flinkcache, fi->flinks[ix]);
+           flink = rpmstrPoolStr(fi->pool, fi->flinks[ix]);
     }
     return flink;
 }
@@ -1076,7 +1076,6 @@ rpmfi rpmfiFree(rpmfi fi)
        fi->bnl = _free(fi->bnl);
        fi->dnl = _free(fi->dnl);
 
-       fi->flinkcache = strcacheFree(fi->flinkcache);
        fi->flinks = _free(fi->flinks);
        fi->flangs = _free(fi->flangs);
        fi->digests = _free(fi->digests);
@@ -1090,6 +1089,8 @@ rpmfi rpmfiFree(rpmfi fi)
        fi->fstates = _free(fi->fstates);
        fi->fps = _free(fi->fps);
 
+       fi->pool = rpmstrPoolFree(fi->pool);
+
        /* these point to header memory if KEEPHEADER is used, dont free */
        if (!(fi->fiflags & RPMFI_KEEPHEADER) && fi->h == NULL) {
            fi->fmtimes = _free(fi->fmtimes);
@@ -1199,6 +1200,7 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTagVal tagN, rpmfiFlags flags)
     /* XXX: ensure the global misc. pool exists */
     if (miscpool == NULL)
        miscpool = rpmstrPoolCreate();
+    fi->pool = rpmstrPoolCreate();
 
     /* XXX TODO: all these should be sanity checked, ugh... */
     if (!(flags & RPMFI_NOFILEMODES))
@@ -1231,10 +1233,8 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTagVal tagN, rpmfiFlags flags)
     if (!(flags & RPMFI_NOFILECAPS))
        _hgfi(h, RPMTAG_FILECAPS, &td, defFlags, fi->fcaps);
 
-    if (!(flags & RPMFI_NOFILELINKTOS)) {
-       fi->flinkcache = strcacheNew();
-       fi->flinks = cacheTag(fi->flinkcache, h, RPMTAG_FILELINKTOS);
-    }
+    if (!(flags & RPMFI_NOFILELINKTOS))
+       fi->flinks = tag2pool(fi->pool, h, RPMTAG_FILELINKTOS);
     /* FILELANGS are only interesting when installing */
     if ((headerGetInstance(h) == 0) && !(flags & RPMFI_NOFILELANGS))
        fi->flangs = tag2pool(miscpool, h, RPMTAG_FILELANGS);
@@ -1285,6 +1285,8 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTagVal tagN, rpmfiFlags flags)
     /* lazily alloced from rpmfiFN() */
     fi->fn = NULL;
 
+    rpmstrPoolFreeze(fi->pool);
+
 exit:
 
     if (fi != NULL) {
index 510d6ce..a657f93 100644 (file)
@@ -23,12 +23,12 @@ struct rpmfi_s {
     int j;                     /*!< Current directory index. */
 
     Header h;                  /*!< Header for file info set (or NULL) */
+    rpmstrPool pool;           /*!< String pool of this file info set */
 
     const char ** bnl;         /*!< Base name(s) (from header) */
     const char ** dnl;         /*!< Directory name(s) (from header) */
 
-    strcache flinkcache;       /*!< File link cache */
-    scidx_t * flinks;          /*!< Index to file link(s) cache */
+    rpmsid * flinks;           /*!< Index to file link(s) (pool) */
 
     uint32_t * dil;            /*!< Directory indice(s) (from header) */
     rpm_flag_t * fflags;       /*!< File flag(s) (from header) */