summaryrefslogtreecommitdiff
path: root/lib/rpmds.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-11 07:40:06 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-11 08:09:07 +0300
commit42f6abba482c792d496bff0f4c9c0d5f04538e8d (patch)
treed4755089072b32c543236a00c29a63a654c9b714 /lib/rpmds.c
parenta596ae47a37e7d855c4697933f48eef043aca4ef (diff)
downloadlibrpm-tizen-42f6abba482c792d496bff0f4c9c0d5f04538e8d.tar.gz
librpm-tizen-42f6abba482c792d496bff0f4c9c0d5f04538e8d.tar.bz2
librpm-tizen-42f6abba482c792d496bff0f4c9c0d5f04538e8d.zip
Add internal indexed variants of rpmds N, EVR and Flags getters
- We'll need these to eliminate the remaining direct accesses to N, EVR (and Flags) on random access patterns such as rpmdsSearch().
Diffstat (limited to 'lib/rpmds.c')
-rw-r--r--lib/rpmds.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/lib/rpmds.c b/lib/rpmds.c
index 9c45cd7fb..d9f414f1b 100644
--- a/lib/rpmds.c
+++ b/lib/rpmds.c
@@ -78,6 +78,30 @@ static int dsType(rpmTagVal tag,
return rc;
}
+static const char * rpmdsNIndex(rpmds ds, int i)
+{
+ const char * N = NULL;
+ if (i >= 0 && i < ds->Count && ds->N != NULL)
+ N = ds->N[i];
+ return N;
+}
+
+static const char * rpmdsEVRIndex(rpmds ds, int i)
+{
+ const char * EVR = NULL;
+ if (i >= 0 && i < ds->Count && ds->EVR != NULL)
+ EVR = ds->EVR[i];
+ return EVR;
+}
+
+static rpmsenseFlags rpmdsFlagsIndex(rpmds ds, int i)
+{
+ rpmsenseFlags Flags = 0;
+ if (i >= 0 && i < ds->Count && ds->Flags != NULL)
+ Flags = ds->Flags[i];
+ return Flags;
+}
+
static rpmds rpmdsUnlink(rpmds ds)
{
if (ds)
@@ -303,35 +327,17 @@ const char * rpmdsDNEVR(const rpmds ds)
const char * rpmdsN(const rpmds ds)
{
- const char * N = NULL;
-
- if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
- if (ds->N != NULL)
- N = ds->N[ds->i];
- }
- return N;
+ return (ds != NULL) ? rpmdsNIndex(ds, ds->i) : NULL;
}
const char * rpmdsEVR(const rpmds ds)
{
- const char * EVR = NULL;
-
- if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
- if (ds->EVR != NULL)
- EVR = ds->EVR[ds->i];
- }
- return EVR;
+ return (ds != NULL) ? rpmdsEVRIndex(ds, ds->i) : NULL;
}
rpmsenseFlags rpmdsFlags(const rpmds ds)
{
- rpmsenseFlags Flags = 0;
-
- if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
- if (ds->Flags != NULL)
- Flags = ds->Flags[ds->i];
- }
- return Flags;
+ return (ds != NULL) ? rpmdsFlagsIndex(ds, ds->i) : 0;
}
rpmTagVal rpmdsTagN(const rpmds ds)