From: Michael Schroeder Date: Mon, 24 Sep 2018 11:04:50 +0000 (+0200) Subject: Improve handing over of the parant kv in subarray searches X-Git-Tag: 0.7.0~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35612b6844665ea02c354c6c963a92563eee3c01;p=thirdparty%2Flibsolv.git Improve handing over of the parant kv in subarray searches We now pass it disguised as keyskip. --- diff --git a/src/dataiterator.h b/src/dataiterator.h index 95877f3a..148c9735 100644 --- a/src/dataiterator.h +++ b/src/dataiterator.h @@ -62,7 +62,8 @@ typedef struct _KeyValue { #define SEARCH_FILES (1<<17) #define SEARCH_CHECKSUMS (1<<18) -/* dataiterator internal */ +/* internal */ +#define SEARCH_SUBSCHEMA (1<<30) #define SEARCH_THISSOLVID (1<<31) /* obsolete */ diff --git a/src/repodata.c b/src/repodata.c index 62ec4610..aa1a8400 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -967,6 +967,9 @@ data_fetch_uninternalized(Repodata *data, Repokey *key, Id value, KeyValue *kv) kv->num = 0; /* not stringified */ kv->str = (const char *)data->attrdata + value; return; + case REPOKEY_TYPE_BINARY: + kv->str = (const char *)data_read_id(data->attrdata + value, (Id *)&kv->num); + return; case REPOKEY_TYPE_IDARRAY: array = data->attriddata + (value + kv->entry); kv->id = array[0]; @@ -1111,17 +1114,12 @@ struct subschema_data { void 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) { - struct subschema_data subd; - subd.solvid = solvid; - subd.cbdata = cbdata; - subd.parent = kv; - repodata_search_keyskip(data, SOLVID_SUBSCHEMA, keyname, flags, 0, callback, &subd); + repodata_search_keyskip(data, solvid, keyname, flags | SEARCH_SUBSCHEMA, (Id *)kv, callback, cbdata); } static int 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) { - struct subschema_data subd; Solvable *s = solvid > 0 ? data->repo->pool->solvables + solvid : 0; unsigned char *dp = (unsigned char *)kv->str; int stop; @@ -1129,9 +1127,6 @@ repodata_search_array(Repodata *data, Id solvid, Id keyname, int flags, Repokey if (!dp || kv->entry != -1) return 0; - subd.solvid = solvid; - subd.cbdata = cbdata; - subd.parent = kv; while (++kv->entry < kv->num) { if (kv->entry) @@ -1145,7 +1140,7 @@ repodata_search_array(Repodata *data, Id solvid, Id keyname, int flags, Repokey if (stop && stop != SEARCH_ENTERSUB) return stop; if ((flags & SEARCH_SUB) != 0 || stop == SEARCH_ENTERSUB) - repodata_search_keyskip(data, SOLVID_SUBSCHEMA, keyname, flags, 0, callback, &subd); + repodata_search_keyskip(data, solvid, keyname, flags | SEARCH_SUBSCHEMA, (Id *)kv, callback, cbdata); } if ((flags & SEARCH_ARRAYSENTINEL) != 0) { @@ -1174,14 +1169,13 @@ repodata_search_keyskip(Repodata *data, Id solvid, Id keyname, int flags, Id *ke if (!maybe_load_repodata(data, keyname)) return; - if (solvid == SOLVID_SUBSCHEMA) - { - struct subschema_data *subd = cbdata; - cbdata = subd->cbdata; - solvid = subd->solvid; - schema = subd->parent->id; - dp = (unsigned char *)subd->parent->str; - kv.parent = subd->parent; + if ((flags & SEARCH_SUBSCHEMA) != 0) + { + flags ^= SEARCH_SUBSCHEMA; + kv.parent = (KeyValue *)keyskip; + keyskip = 0; + schema = kv.parent->id; + dp = (unsigned char *)kv.parent->str; } else { diff --git a/src/repodata.h b/src/repodata.h index 05d34a80..81248852 100644 --- a/src/repodata.h +++ b/src/repodata.h @@ -143,7 +143,6 @@ typedef struct _Repodata { #define SOLVID_META -1 #define SOLVID_POS -2 -#define SOLVID_SUBSCHEMA -3 /* internal! */ /*-----