- some more cleanup
authorMichael Schroeder <mls@suse.de>
Sat, 17 Nov 2007 19:43:47 +0000 (19:43 +0000)
committerMichael Schroeder <mls@suse.de>
Sat, 17 Nov 2007 19:43:47 +0000 (19:43 +0000)
src/pool.c
src/pool.h
src/repo.c
src/repo.h
src/solver.c

index 553f698..4655afd 100644 (file)
@@ -107,7 +107,7 @@ pool_free(Pool *pool)
 
   pool_freewhatprovides(pool);
   pool_freeidhashes(pool);
-  pool_freeallrepos(pool, 1);
+  repo_freeallrepos(pool, 1);
   xfree(pool->id2arch);
   xfree(pool->solvables);
   xfree(pool->ss.stringspace);
@@ -263,14 +263,14 @@ pool_shrink_whatprovides(Pool *pool)
 
 
 /*
- * pool_prepare()
+ * pool_createwhatprovides()
  * 
  * create hashes over complete pool to ease lookups
  * 
  */
 
 void
-pool_prepare(Pool *pool)
+pool_createwhatprovides(Pool *pool)
 {
   int i, num, np, extra;
   Offset off;
@@ -452,8 +452,8 @@ pool_addrelproviders(Pool *pool, Id d)
     {
     case REL_AND:
     case REL_WITH:
-      pp = GET_PROVIDESP(name, p);
-      pp2 = GET_PROVIDESP(evr, p);
+      pp = pool_whatprovides(pool, name);
+      pp2 = pool_whatprovides(pool, evr);
       while ((p = *pp++) != 0)
        {
          for (pp3 = pp2; *pp3;)
@@ -465,10 +465,10 @@ pool_addrelproviders(Pool *pool, Id d)
        }
       break;
     case REL_OR:
-      pp = GET_PROVIDESP(name, p);
+      pp = pool_whatprovides(pool, name);
       while ((p = *pp++) != 0)
        queue_push(&plist, p);
-      pp = GET_PROVIDESP(evr, p);
+      pp = pool_whatprovides(pool, evr);
       while ((p = *pp++) != 0)
        queue_pushunique(&plist, p);
       break;
index 8231055..9bab59e 100644 (file)
@@ -111,20 +111,6 @@ struct _Pool {
 
 //-----------------------------------------------
 
-// whatprovides
-//  "foo" -> Id -> lookup in table, returns offset into whatprovidesdata where array of Ids providing 'foo' are located, 0-terminated
-
-
-#define GET_PROVIDESP(d, v) (ISRELDEP(d) ?                             \
-             (v = GETRELID(pool, d), pool->whatprovides[v] ?           \
-               pool->whatprovidesdata + pool->whatprovides[v] :                \
-              pool_addrelproviders(pool, d)                            \
-             ) :                                                       \
-             (pool->whatprovidesdata + pool->whatprovides[d]))
-
-/* loop over all providers of d */
-#define FOR_PROVIDES(v, vp, d)                                                 \
-  for (vp = GET_PROVIDESP(d, v) ; (v = *vp++) != ID_NULL; )
 
 /* mark dependencies with relation by setting bit31 */
 
@@ -167,12 +153,10 @@ static inline Solvable *pool_id2solvable(Pool *pool, Id p)
 /**
  * Prepares a pool for solving
  */
-extern void pool_prepare(Pool *pool);
+extern void pool_createwhatprovides(Pool *pool);
 extern void pool_freewhatprovides(Pool *pool);
 extern Id pool_queuetowhatprovides(Pool *pool, Queue *q);
 
-extern Id *pool_addrelproviders(Pool *pool, Id d);
-
 static inline int pool_installable(Pool *pool, Solvable *s)
 {
   if (!s->arch || s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
@@ -182,6 +166,24 @@ static inline int pool_installable(Pool *pool, Solvable *s)
   return 1;
 }
 
+extern Id *pool_addrelproviders(Pool *pool, Id d);
+
+static inline Id *pool_whatprovides(Pool *pool, Id d)
+{
+  Id v;
+  if (!ISRELDEP(d))
+    return pool->whatprovidesdata + pool->whatprovides[d];
+  v = GETRELID(pool, d);
+  if (pool->whatprovides[v])
+    return pool->whatprovidesdata + pool->whatprovides[v];
+  return pool_addrelproviders(pool, d);
+}
+
+/* loop over all providers of d */
+#define FOR_PROVIDES(v, vp, d)                                                 \
+  for (vp = pool_whatprovides(pool, d) ; (v = *vp++) != 0; )
+
+
 #ifdef __cplusplus
 }
 #endif
index 9f00727..5c7828f 100644 (file)
@@ -286,7 +286,7 @@ repo_free(Repo *repo, int reuseids)
 }
 
 void
-pool_freeallrepos(Pool *pool, int reuseids)
+repo_freeallrepos(Pool *pool, int reuseids)
 {
   int i;
 
index 82ac9f2..2b4e24c 100644 (file)
@@ -34,14 +34,13 @@ typedef struct _Repo {
 
 extern Repo *repo_create(Pool *pool, const char *name);
 extern void repo_free(Repo *repo, int reuseids);
+extern void repo_freeallrepos(Pool *pool, int reuseids);
 
 extern Offset repo_addid(Repo *repo, Offset olddeps, Id id);
 extern Offset repo_addid_dep(Repo *repo, Offset olddeps, Id id, int isreq);
 extern Offset repo_reserve_ids(Repo *repo, Offset olddeps, int num);
 extern Offset repo_fix_legacy(Repo *repo, Offset provides, Offset supplements);
 
-extern void pool_freeallrepos(Pool *pool, int reuseids);
-
 static inline const char *repo_name(const Repo *repo)
 {
   return repo->name;
index 2e9279f..d8aa429 100644 (file)
@@ -953,7 +953,7 @@ addrpmrulesforsolvable(Solver *solv, Solvable *s, Map *m)
              if (req == SOLVABLE_PREREQMARKER)   /* skip the marker */
                continue;
 
-             dp = GET_PROVIDESP(req, p);       /* get providers of req; p is a dummy only */ 
+             dp = pool_whatprovides(pool, req);
 
              if (*dp == SYSTEMSOLVABLE)        /* always installed */
                continue;
@@ -2886,7 +2886,7 @@ printprobleminfo(Solver *solv, Queue *job, Id problem)
            {
              if (req == SOLVABLE_PREREQMARKER)
                continue;
-             dp = GET_PROVIDESP(req, p);
+             dp = pool_whatprovides(pool, req);
              if (*dp)
                continue;
              printf("package %s-%s.%s requires %s, but no package provides it\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch), dep2str(pool, req));
@@ -2950,7 +2950,7 @@ printprobleminfo(Solver *solv, Queue *job, Id problem)
        {
          if (req == SOLVABLE_PREREQMARKER)
            continue;
-         dp = GET_PROVIDESP(req, p);
+         dp = pool_whatprovides(pool, req);
           if (d == 0)
            {
              if (*dp == r->w2 && dp[1] == 0)