From: Michael Schroeder Date: Thu, 20 Dec 2012 16:12:02 +0000 (+0100) Subject: improve repo_add_rpmdb speed a tiny bit X-Git-Tag: submit/trunk/20130208.042515~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0951f9f60b9f227bbb2595c136d0a7c67806f2d;p=platform%2Fupstream%2Flibsolv.git improve repo_add_rpmdb speed a tiny bit --- diff --git a/ext/pool_fileconflicts.c b/ext/pool_fileconflicts.c index 5b51bee..806cdb1 100644 --- a/ext/pool_fileconflicts.c +++ b/ext/pool_fileconflicts.c @@ -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; diff --git a/ext/repo_rpmdb.c b/ext/repo_rpmdb.c index c5aa0fc..7ea6913 100644 --- a/ext/repo_rpmdb.c +++ b/ext/repo_rpmdb.c @@ -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