Skip to content

Commit 35612b6

Browse files
committed
Improve handing over of the parant kv in subarray searches
We now pass it disguised as keyskip.
1 parent affa917 commit 35612b6

3 files changed

Lines changed: 14 additions & 20 deletions

File tree

src/dataiterator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ typedef struct _KeyValue {
6262
#define SEARCH_FILES (1<<17)
6363
#define SEARCH_CHECKSUMS (1<<18)
6464

65-
/* dataiterator internal */
65+
/* internal */
66+
#define SEARCH_SUBSCHEMA (1<<30)
6667
#define SEARCH_THISSOLVID (1<<31)
6768

6869
/* obsolete */

src/repodata.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,9 @@ data_fetch_uninternalized(Repodata *data, Repokey *key, Id value, KeyValue *kv)
967967
kv->num = 0; /* not stringified */
968968
kv->str = (const char *)data->attrdata + value;
969969
return;
970+
case REPOKEY_TYPE_BINARY:
971+
kv->str = (const char *)data_read_id(data->attrdata + value, (Id *)&kv->num);
972+
return;
970973
case REPOKEY_TYPE_IDARRAY:
971974
array = data->attriddata + (value + kv->entry);
972975
kv->id = array[0];
@@ -1111,27 +1114,19 @@ struct subschema_data {
11111114
void
11121115
repodata_search_arrayelement(Repodata *data, Id solvid, Id keyname, int flags, KeyValue *kv, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *kv), void *cbdata)
11131116
{
1114-
struct subschema_data subd;
1115-
subd.solvid = solvid;
1116-
subd.cbdata = cbdata;
1117-
subd.parent = kv;
1118-
repodata_search_keyskip(data, SOLVID_SUBSCHEMA, keyname, flags, 0, callback, &subd);
1117+
repodata_search_keyskip(data, solvid, keyname, flags | SEARCH_SUBSCHEMA, (Id *)kv, callback, cbdata);
11191118
}
11201119

11211120
static int
11221121
repodata_search_array(Repodata *data, Id solvid, Id keyname, int flags, Repokey *key, KeyValue *kv, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *kv), void *cbdata)
11231122
{
1124-
struct subschema_data subd;
11251123
Solvable *s = solvid > 0 ? data->repo->pool->solvables + solvid : 0;
11261124
unsigned char *dp = (unsigned char *)kv->str;
11271125
int stop;
11281126
Id schema = 0;
11291127

11301128
if (!dp || kv->entry != -1)
11311129
return 0;
1132-
subd.solvid = solvid;
1133-
subd.cbdata = cbdata;
1134-
subd.parent = kv;
11351130
while (++kv->entry < kv->num)
11361131
{
11371132
if (kv->entry)
@@ -1145,7 +1140,7 @@ repodata_search_array(Repodata *data, Id solvid, Id keyname, int flags, Repokey
11451140
if (stop && stop != SEARCH_ENTERSUB)
11461141
return stop;
11471142
if ((flags & SEARCH_SUB) != 0 || stop == SEARCH_ENTERSUB)
1148-
repodata_search_keyskip(data, SOLVID_SUBSCHEMA, keyname, flags, 0, callback, &subd);
1143+
repodata_search_keyskip(data, solvid, keyname, flags | SEARCH_SUBSCHEMA, (Id *)kv, callback, cbdata);
11491144
}
11501145
if ((flags & SEARCH_ARRAYSENTINEL) != 0)
11511146
{
@@ -1174,14 +1169,13 @@ repodata_search_keyskip(Repodata *data, Id solvid, Id keyname, int flags, Id *ke
11741169

11751170
if (!maybe_load_repodata(data, keyname))
11761171
return;
1177-
if (solvid == SOLVID_SUBSCHEMA)
1178-
{
1179-
struct subschema_data *subd = cbdata;
1180-
cbdata = subd->cbdata;
1181-
solvid = subd->solvid;
1182-
schema = subd->parent->id;
1183-
dp = (unsigned char *)subd->parent->str;
1184-
kv.parent = subd->parent;
1172+
if ((flags & SEARCH_SUBSCHEMA) != 0)
1173+
{
1174+
flags ^= SEARCH_SUBSCHEMA;
1175+
kv.parent = (KeyValue *)keyskip;
1176+
keyskip = 0;
1177+
schema = kv.parent->id;
1178+
dp = (unsigned char *)kv.parent->str;
11851179
}
11861180
else
11871181
{

src/repodata.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ typedef struct _Repodata {
143143

144144
#define SOLVID_META -1
145145
#define SOLVID_POS -2
146-
#define SOLVID_SUBSCHEMA -3 /* internal! */
147146

148147

149148
/*-----

0 commit comments

Comments
 (0)