improve repo_add_rpmdb speed a tiny bit
authorMichael Schroeder <mls@suse.de>
Thu, 20 Dec 2012 16:12:02 +0000 (17:12 +0100)
committerMichael Schroeder <mls@suse.de>
Thu, 20 Dec 2012 16:12:02 +0000 (17:12 +0100)
ext/pool_fileconflicts.c
ext/repo_rpmdb.c

index 5b51bee..806cdb1 100644 (file)
@@ -152,7 +152,7 @@ findfileconflicts_cb(void *cbdatav, const char *fn, int fmode, const char *md5)
     return;
   dhx = strnhash(fn, dp + 1 - fn);
   if (!dhx)
-    dhx = 1 + dp + 1 - fn;
+    dhx = dp + 1 - fn + 1;     /* mirrors the "if (!hx) hx = strlen(fn) + 1" in finddirs_cb */
 #if 1
   if (!isindirmap(cbdata, dhx))
     return;
index c5aa0fc..7ea6913 100644 (file)
@@ -720,6 +720,8 @@ addfileprovides(Pool *pool, Repo *repo, Repodata *data, Solvable *s, RpmHead *rp
   unsigned int *di;
   int bnc, dnc, dic;
   int i;
+  Id lastdid = 0;
+  int lastdii = -1;
 #ifdef USE_FILEFILTER
   int j;
   struct filefilter *ff;
@@ -804,18 +806,22 @@ addfileprovides(Pool *pool, Repo *repo, Repodata *data, Solvable *s, RpmHead *rp
 #endif
       if (data)
        {
-         Id handle, did;
+         Id did;
          char *b = bn[i];
 
-         handle = s - pool->solvables;
-         did = repodata_str2dir(data, dn[di[i]], 1);
-         if (!did)
+         if (di[i] == lastdii)
+           did = lastdid;
+         else
            {
-             did = repodata_str2dir(data, "/", 1);
-             if (b && b[0] == '/')
-               b++;    /* work around rpm bug */
+             did = repodata_str2dir(data, dn[di[i]], 1);
+             if (!did)
+               did = repodata_str2dir(data, "/", 1);
+             lastdid = did;
+             lastdii = di[i];
            }
-         repodata_add_dirstr(data, handle, SOLVABLE_FILELIST, did, b);
+         if (b && *b == '/')   /* work around rpm bug */
+           b++;
+         repodata_add_dirstr(data, s - pool->solvables, SOLVABLE_FILELIST, did, b);
        }
     }
 #if 0