From: Michael Schroeder Date: Mon, 10 Sep 2018 09:47:00 +0000 (+0200) Subject: Add an internal repodata_lookup_packed_dirstrarray function X-Git-Tag: 0.7.0~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=150c40c2ddf6a1575da8b448cb01b6eeeacc0caf;p=thirdparty%2Flibsolv.git Add an internal repodata_lookup_packed_dirstrarray function This is faster than using repo_search to iterate over the filelist. We will use it in the new addfileprovides code. --- diff --git a/src/repodata.c b/src/repodata.c index aca80a3e..b08a8362 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -781,6 +781,48 @@ repodata_lookup_binary(Repodata *data, Id solvid, Id keyname, int *lenp) return dp; } +/* highly specialized function to speed up fileprovides adding. + * - repodata must be available + * - solvid must be >= data->start and < data->end + * - returns NULL is not found, a "" entry if wrong type + * - also returns wrong type for REPOKEY_TYPE_DELETED + */ +const unsigned char * +repodata_lookup_packed_dirstrarray(Repodata *data, Id solvid, Id keyname) +{ + static unsigned char wrongtype[2] = { 0x00 /* dir id 0 */, 0 /* "" */ }; + unsigned char *dp; + Id schema, *keyp, *kp; + Repokey *key; + + if (!data->incoredata || !data->incoreoffset[solvid - data->start]) + return 0; + dp = data->incoredata + data->incoreoffset[solvid - data->start]; + dp = data_read_id(dp, &schema); + keyp = data->schemadata + data->schemata[schema]; + for (kp = keyp; *kp; kp++) + if (data->keys[*kp].name == keyname) + break; + if (!*kp) + return 0; + key = data->keys + *kp; + if (key->type != REPOKEY_TYPE_DIRSTRARRAY) + return wrongtype; + dp = forward_to_key(data, *kp, keyp, dp); + if (key->storage == KEY_STORAGE_INCORE) + return dp; + if (key->storage == KEY_STORAGE_VERTICAL_OFFSET && dp) + { + Id off, len; + dp = data_read_id(dp, &off); + data_read_id(dp, &len); + return get_vertical_data(data, key, off, len); + } + return 0; +} + +/* id translation functions */ + Id repodata_globalize_id(Repodata *data, Id id, int create) { @@ -814,6 +856,8 @@ repodata_translate_id(Repodata *data, Repodata *fromdata, Id id, int create) return stringpool_str2id(&data->spool, stringpool_id2str(&fromdata->spool, id), create); } +/* uninternalized lookups */ + Id repodata_lookup_id_uninternalized(Repodata *data, Id solvid, Id keyname, Id voidid) { @@ -836,6 +880,7 @@ repodata_lookup_id_uninternalized(Repodata *data, Id solvid, Id keyname, Id void return 0; } +/* returns the basename, stores the dir id in didp */ const char * repodata_lookup_dirstrarray_uninternalized(Repodata *data, Id solvid, Id keyname, Id *didp, Id *iterp) { diff --git a/src/repodata.h b/src/repodata.h index 9dcfc729..186ee798 100644 --- a/src/repodata.h +++ b/src/repodata.h @@ -229,6 +229,9 @@ const unsigned char *repodata_lookup_bin_checksum(Repodata *data, Id solvid, Id int repodata_lookup_idarray(Repodata *data, Id solvid, Id keyname, Queue *q); const void *repodata_lookup_binary(Repodata *data, Id solvid, Id keyname, int *lenp); +/* internal, used in fileprovides code */ +const unsigned char *repodata_lookup_packed_dirstrarray(Repodata *data, Id solvid, Id keyname); + /*----- * data assignment functions