]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Split away solvable_matchessolvable_int function
authorMichael Schroeder <mls@suse.de>
Mon, 8 Oct 2018 11:21:51 +0000 (13:21 +0200)
committerMichael Schroeder <mls@suse.de>
Mon, 8 Oct 2018 11:21:51 +0000 (13:21 +0200)
To be used in the selection code as well.

src/pool.c
src/solvable.c
src/solvable.h

index aa994cc7660da273e05c806ec01d634a95ed665a..1db225616efd48457ded7c26e4cfa51002d820b2 100644 (file)
@@ -1491,11 +1491,10 @@ pool_whatcontainsdep(Pool *pool, Id keyname, Id dep, Queue *q, int marker)
 void
 pool_whatmatchessolvable(Pool *pool, Id keyname, Id solvid, Queue *q, int marker)
 {
-  Id p, *wp;
+  Id p;
   Queue qq;
-  int i;
   Map missc;           /* cache for misses */
-  int reloff, boff;
+  int reloff;
 
   queue_empty(q);
   queue_init(&qq);
@@ -1510,47 +1509,8 @@ pool_whatmatchessolvable(Pool *pool, Id keyname, Id solvid, Queue *q, int marker
        continue;
       if (s->repo != pool->installed && !pool_installable(pool, s))
        continue;
-      if (qq.count)
-       queue_empty(&qq);
-      solvable_lookup_deparray(s, keyname, &qq, marker);
-      for (i = 0; i < qq.count; i++)
-       {
-         Id dep = qq.elements[i];
-         boff = ISRELDEP(dep) ? reloff + GETRELID(dep) : dep;
-         if (MAPTST(&missc, boff))
-           continue;
-         if (ISRELDEP(dep))
-           {
-             Reldep *rd = GETRELDEP(pool, dep);
-             if (!ISRELDEP(rd->name) && rd->flags < 8)
-               {
-                 /* do pre-filtering on the base */
-                 if (MAPTST(&missc, rd->name))
-                   continue;
-                 wp = pool_whatprovides_ptr(pool, rd->name);
-                 for (wp = pool_whatprovides_ptr(pool, dep); *wp; wp++)
-                   if (*wp == solvid)
-                     break;
-                 if (!*wp)
-                   {
-                     /* the base does not include solvid, no need to check the complete dep */
-                     MAPSET(&missc, rd->name);
-                     MAPSET(&missc, boff);
-                     continue;
-                   }
-               }
-           }
-         wp = pool_whatprovides_ptr(pool, dep);
-         for (wp = pool_whatprovides_ptr(pool, dep); *wp; wp++)
-           if (*wp == solvid)
-             break;
-         if (*wp)
-           {
-             queue_push(q, p);
-             break;
-           }
-         MAPSET(&missc, boff);
-       }
+      if (solvable_matchessolvable_int(s, keyname, marker, solvid, 0, &qq, &missc, reloff))
+        queue_push(q, p);
     }
   map_free(&missc);
   queue_free(&qq);
index 6f6ba1de2d0bda0ae3e0ca7834b96d954ae89ff8..8b2f079b85629a9b9e41bf4da0c2e6e78a5a517e 100644 (file)
@@ -613,3 +613,67 @@ solvable_matchesdep(Solvable *s, Id keyname, Id dep, int marker)
   queue_free(&q);
   return i;
 }
+
+int
+solvable_matchessolvable_int(Solvable *s, Id keyname, int marker, Id solvid, Map *solvidmap, Queue *depq, Map *missc, int reloff)
+{
+  Pool *pool = s->repo->pool;
+  int i, boff;
+  Id *wp;
+
+  if (depq->count)
+    queue_empty(depq);
+  solvable_lookup_deparray(s, keyname, depq, marker);
+  for (i = 0; i < depq->count; i++)
+    {
+      Id dep = depq->elements[i];
+      boff = ISRELDEP(dep) ? reloff + GETRELID(dep) : dep;
+      if (MAPTST(missc, boff))
+       continue;
+      if (ISRELDEP(dep))
+       {
+         Reldep *rd = GETRELDEP(pool, dep);
+         if (!ISRELDEP(rd->name) && rd->flags < 8)
+           {
+             /* do pre-filtering on the base */
+             if (MAPTST(missc, rd->name))
+               continue;
+             wp = pool_whatprovides_ptr(pool, rd->name);
+             if (solvidmap)
+               {
+                 for (; *wp; wp++)
+                   if (MAPTST(solvidmap, *wp))
+                     break;
+               }
+             else
+               {
+                 for (; *wp; wp++)
+                   if (*wp == solvid)
+                     break;
+               }
+             if (!*wp)
+               {
+                 /* the base does not include solvid, no need to check the complete dep */
+                 MAPSET(missc, rd->name);
+                 MAPSET(missc, boff);
+                 continue;
+               }
+           }
+       }
+      wp = pool_whatprovides_ptr(pool, dep);
+      if (solvidmap)
+       {
+         for (; *wp; wp++)
+           if (MAPTST(solvidmap, *wp))
+             return 1;
+       }
+      else
+       {
+         for (; *wp; wp++)
+           if (*wp == solvid)
+             return 1;
+       }
+      MAPSET(missc, boff);
+    }
+  return 0;
+}
index 090b7588bda9480e1c874c8165517d90f3983439..7808e1ac3a8968f0091bdfc73461780e704b9e37 100644 (file)
@@ -79,8 +79,13 @@ void solvable_unset(Solvable *s, Id keyname);
 
 int solvable_identical(Solvable *s1, Solvable *s2);
 Id solvable_selfprovidedep(Solvable *s);
+
 int solvable_matchesdep(Solvable *s, Id keyname, Id dep, int marker);
 
+/* internal */
+int solvable_matchessolvable_int(Solvable *s, Id keyname, int marker, Id solvid, Map *solvidmap, Queue *depq, Map *missc, int reloff);
+
+
 /* weird suse stuff */
 int solvable_is_irrelevant_patch(Solvable *s, Map *installedmap);
 int solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsmap, Map *multiversionmap);