summaryrefslogtreecommitdiff
path: root/lib/rpmds.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-11 07:25:04 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-11 08:08:59 +0300
commita596ae47a37e7d855c4697933f48eef043aca4ef (patch)
tree053cabd3aefb97139491d9bb34caf279d69c34c3 /lib/rpmds.c
parentd2f51ded49d438f3c6c6026ff4202196c94f2651 (diff)
downloadlibrpm-tizen-a596ae47a37e7d855c4697933f48eef043aca4ef.tar.gz
librpm-tizen-a596ae47a37e7d855c4697933f48eef043aca4ef.tar.bz2
librpm-tizen-a596ae47a37e7d855c4697933f48eef043aca4ef.zip
Clean up rpmdsFind() a bit
- Eliminate numerous repeated direct accesses to [o]ds N, EVR and Flags, instead grab them into local variables through getter functions as needed: on entry for ods which doesn't change, for ds in the loop as we're changing ds->i here.
Diffstat (limited to 'lib/rpmds.c')
-rw-r--r--lib/rpmds.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/rpmds.c b/lib/rpmds.c
index d9a039c78..9c45cd7fb 100644
--- a/lib/rpmds.c
+++ b/lib/rpmds.c
@@ -494,6 +494,10 @@ assert(ods->Flags != NULL);
int rpmdsFind(rpmds ds, const rpmds ods)
{
int comparison;
+ const char *N, *ON = rpmdsN(ods);
+ const char *EVR, *OEVR = rpmdsEVR(ods);
+ rpmsenseFlags Flags, OFlags = rpmdsFlags(ods);
+ int rc = -1; /* assume not found */
if (ds == NULL || ods == NULL)
return -1;
@@ -503,22 +507,28 @@ int rpmdsFind(rpmds ds, const rpmds ods)
while (ds->l < ds->u) {
ds->i = (ds->l + ds->u) / 2;
- comparison = strcmp(ods->N[ods->i], ds->N[ds->i]);
+ N = rpmdsN(ds);
+ EVR = rpmdsEVR(ds);
+ Flags = rpmdsFlags(ds);
+
+ comparison = strcmp(ON, N);
/* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
- if (comparison == 0 && ods->EVR && ds->EVR)
- comparison = strcmp(ods->EVR[ods->i], ds->EVR[ds->i]);
- if (comparison == 0 && ods->Flags && ds->Flags)
- comparison = (ods->Flags[ods->i] - ds->Flags[ds->i]);
+ if (comparison == 0 && OEVR && EVR)
+ comparison = strcmp(OEVR, EVR);
+ if (comparison == 0 && OFlags && Flags)
+ comparison = OFlags - Flags;
if (comparison < 0)
ds->u = ds->i;
else if (comparison > 0)
ds->l = ds->i + 1;
- else
- return ds->i;
+ else {
+ rc = ds->i;
+ break;
+ }
}
- return -1;
+ return rc;
}
int rpmdsMerge(rpmds * dsp, rpmds ods)