Use per-rpmfi string cache for symlink targets
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 20 Nov 2008 08:26:22 +0000 (10:26 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 20 Nov 2008 08:26:22 +0000 (10:26 +0200)
- few files are actually symlinks so this is very sparse data
- per-rpmfi instead of global as link target names are not that likely
  to be shared across packages
- another few megs saved...

lib/rpmfi.c
lib/rpmfi_internal.h

index 8cfdea1..858c793 100644 (file)
@@ -290,7 +290,7 @@ const char * rpmfiFLink(rpmfi fi)
 
     if (fi != NULL && fi->i >= 0 && fi->i < fi->fc) {
        if (fi->flinks != NULL)
-           flink = fi->flinks[fi->i];
+           flink = strcacheGet(fi->flinkcache, fi->flinks[fi->i]);
     }
     return flink;
 }
@@ -1217,6 +1217,7 @@ fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, fi->Type, fi->fc);
        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);
@@ -1400,8 +1401,10 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTag tagN, rpmfiFlags flags)
        }
     }
 
-    if (!(flags & RPMFI_NOFILELINKTOS))
-       _hgfi(h, RPMTAG_FILELINKTOS, &td, defFlags, fi->flinks);
+    if (!(flags & RPMFI_NOFILELINKTOS)) {
+       fi->flinkcache = strcacheNew();
+       fi->flinks = cacheTag(fi->flinkcache, h, RPMTAG_FILELINKTOS);
+    }
     /* FILELANGS are only interesting when installing */
     if ((headerGetInstance(h) == 0) && !(flags & RPMFI_NOFILELANGS))
        fi->flangs = cacheTag(langcache, h, RPMTAG_FILELANGS);
index 5de407d..31d2f21 100644 (file)
@@ -42,7 +42,8 @@ struct rpmfi_s {
 /*?null?*/
     const char ** dnl;         /*!< Directory name(s) (from header) */
 
-    const char ** flinks;      /*!< File link(s) (from header) */
+    strcache flinkcache;       /*!< File link cache */
+    scidx_t * flinks;          /*!< Index to file link(s) cache */
     scidx_t * flangs;          /*!< Index to file lang(s) cache */
 
           uint32_t * dil;      /*!< Directory indice(s) (from header) */