diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-03-18 19:55:57 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-03-18 19:58:39 +0200 |
commit | c1a677e839a7d3efae41f95c5e0d10a974b9db7b (patch) | |
tree | a0826d1ddf62e2dd5840bd38594f78e3ed40e3c2 | |
parent | ec1e62230739735e314def0f494506ed08dd028e (diff) | |
download | rpm-c1a677e839a7d3efae41f95c5e0d10a974b9db7b.tar.gz rpm-c1a677e839a7d3efae41f95c5e0d10a974b9db7b.tar.bz2 rpm-c1a677e839a7d3efae41f95c5e0d10a974b9db7b.zip |
Lazy rpmal hash creation on first lookup, make rpmalMakeIndex() static
- the "new" hash-based rpmal only uses rpmalMakeIndex() for initial
creation of the hash tables as late as possible for better estimate
of needed hash size, but doesn't require any index regeneration if something
is added
- first call to rpmalSatisfiedDepend() now initializes the hashes, if
significant amount of entries are added after the first call hash
table might get full ... so dont do that ;) (this was already true
with rpmalMakeIndex(), now its just hidden out of sight)
-rw-r--r-- | lib/depends.c | 4 | ||||
-rw-r--r-- | lib/order.c | 7 | ||||
-rw-r--r-- | lib/rpmal.c | 5 | ||||
-rw-r--r-- | lib/rpmal.h | 7 |
4 files changed, 4 insertions, 19 deletions
diff --git a/lib/depends.c b/lib/depends.c index 87d4deb2b..f884648fe 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -433,7 +433,6 @@ retry: goto exit; if (xx == -1) { retrying = 1; - rpmalMakeIndex(tsmem->addedPackages); goto retry; } } @@ -521,7 +520,6 @@ static void checkInstDeps(rpmts ts, depCache dcache, rpmte te, int rpmtsCheck(rpmts ts) { - tsMembers tsmem = rpmtsMembers(ts); rpm_color_t tscolor = rpmtsColor(ts); rpmtsi pi = NULL; rpmte p; int closeatexit = 0; @@ -537,8 +535,6 @@ int rpmtsCheck(rpmts ts) closeatexit = 1; } - rpmalMakeIndex(tsmem->addedPackages); - /* XXX FIXME: figure some kind of heuristic for the cache size */ dcache = depCacheCreate(5001, hashFunctionString, strcmp, (depCacheFreeKey)rfree, NULL); diff --git a/lib/order.c b/lib/order.c index 1cbd96544..f82ca6ac4 100644 --- a/lib/order.c +++ b/lib/order.c @@ -571,19 +571,12 @@ int rpmtsOrder(rpmts ts) (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_ORDER), 0); - /* - * XXX FIXME: this gets needlesly called twice on normal usage patterns, - * should track the need for generating the index somewhere - */ - rpmalMakeIndex(tsmem->addedPackages); - /* Create erased package index. */ pi = rpmtsiInit(ts); while ((p = rpmtsiNext(pi, TR_REMOVED)) != NULL) { rpmalAdd(erasedPackages, p); } pi = rpmtsiFree(pi); - rpmalMakeIndex(erasedPackages); for (int i = 0; i < nelem; i++) { sortInfo[i].te = tsmem->order[i]; diff --git a/lib/rpmal.c b/lib/rpmal.c index 575d1be1c..e792ddf45 100644 --- a/lib/rpmal.c +++ b/lib/rpmal.c @@ -244,7 +244,7 @@ void rpmalAdd(rpmal al, rpmte p) assert(((rpmalNum)(alp - al->list)) == pkgNum); } -void rpmalMakeIndex(rpmal al) +static void rpmalMakeIndex(rpmal al) { availablePackage alp; int i; @@ -333,6 +333,9 @@ static rpmte * rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds) if (al == NULL || ds == NULL || (name = rpmdsN(ds)) == NULL) return ret; + if (al->providesHash == NULL && al->fileHash == NULL) + rpmalMakeIndex(al); + if (*name == '/') { /* First, look for files "contained" in package ... */ ret = rpmalAllFileSatisfiesDepend(al, ds); diff --git a/lib/rpmal.h b/lib/rpmal.h index 26407364f..aff5554c4 100644 --- a/lib/rpmal.h +++ b/lib/rpmal.h @@ -54,13 +54,6 @@ void rpmalAdd(rpmal al, rpmte p); /** - * Generate index for available list. - * @param al available list - */ -RPM_GNUC_INTERNAL -void rpmalMakeIndex(rpmal al); - -/** * Lookup best provider for a dependency in the available list * @param al available list * @param ds dependency set |