From a4af3e80f8f20b540b42358106e019443f9c7ad2 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 5 Sep 2012 11:02:14 +0300 Subject: [PATCH] Prehash dependency strings to avoid recalculating when caching - Speedup depends on the transaction and is likely to be rather modest anyway, but can't hurt either... --- lib/depends.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/depends.c b/lib/depends.c index 7350e27..ad9b577 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -407,12 +407,16 @@ static int rpmdbProvides(rpmts ts, depCache dcache, rpmds dep) int rc = 0; /* pretrans deps are provided by current packages, don't prune erasures */ int prune = (rpmdsFlags(dep) & RPMSENSE_PRETRANS) ? 0 : 1; + unsigned int keyhash = 0; /* See if we already looked this up */ - if (prune && depCacheGetEntry(dcache, DNEVR, &cachedrc, NULL, NULL)) { - rc = *cachedrc; - rpmdsNotify(dep, "(cached)", rc); - return rc; + if (prune) { + keyhash = depCacheKeyHash(dcache, DNEVR); + if (depCacheGetHEntry(dcache, DNEVR, keyhash, &cachedrc, NULL, NULL)) { + rc = *cachedrc; + rpmdsNotify(dep, "(cached)", rc); + return rc; + } } /* @@ -457,7 +461,7 @@ static int rpmdbProvides(rpmts ts, depCache dcache, rpmds dep) /* Cache the relatively expensive rpmdb lookup results */ /* Caching the oddball non-pruned case would mess up other results */ if (prune) - depCacheAddEntry(dcache, xstrdup(DNEVR), rc); + depCacheAddHEntry(dcache, xstrdup(DNEVR), keyhash, rc); return rc; } -- 2.7.4