]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Add an internal repodata_lookup_packed_dirstrarray function
authorMichael Schroeder <mls@suse.de>
Mon, 10 Sep 2018 09:47:00 +0000 (11:47 +0200)
committerMichael Schroeder <mls@suse.de>
Mon, 10 Sep 2018 09:47:00 +0000 (11:47 +0200)
This is faster than using repo_search to iterate over the
filelist. We will use it in the new addfileprovides code.

src/repodata.c
src/repodata.h

index aca80a3e7e2f410e2befbb765f5edf0921b893c1..b08a8362054049abf5a721beae6a6ab772632975 100644 (file)
@@ -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)
 {
index 9dcfc7295b3fdbc122ad034cc0c6010dea9bd6a3..186ee7982bc0d0b61c439ee04df16a78f3d8ac9d 100644 (file)
@@ -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