- beautfy, rename & document
authorMichael Schroeder <mls@suse.de>
Fri, 11 Apr 2008 10:07:01 +0000 (10:07 +0000)
committerMichael Schroeder <mls@suse.de>
Fri, 11 Apr 2008 10:07:01 +0000 (10:07 +0000)
src/pool.h
src/solvable.c
src/solver.c
src/solver.h

index 965ce58..c29687a 100644 (file)
@@ -180,7 +180,8 @@ const char *solvable_lookup_checksum(Solvable *s, Id keyname, Id *typep);
 int solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsmap);
 int solvable_trivial_installable_repo(Solvable *s, struct _Repo *installed);
 int solvable_trivial_installable_queue(Solvable *s, Queue *installed);
-void create_trivial_installable_maps(Pool *pool, Queue *installed, Map *installedmap, Map *conflictsmap);
+
+void pool_create_state_maps(Pool *pool, Queue *installed, Map *installedmap, Map *conflictsmap);
 
 
 
index a0d9648..b4d5ddf 100644 (file)
@@ -359,6 +359,7 @@ solvable_get_location(Solvable *s, unsigned int *medianrp)
   return loc;
 }
 
+/*****************************************************************************/
 
 static inline Id dep2name(Pool *pool, Id dep)
 {
@@ -384,6 +385,16 @@ static inline int providedbyinstalled(Pool *pool, Map *installed, Id dep)
 }
 
 /*
+ * solvable_trivial_installable_map - anwers is a solvable is installable
+ * without any other installs/deinstalls.
+ * The packages considered to be installed are provided via the
+ * installedmap bitmap. A additional "conflictsmap" bitmap providing
+ * information about the conflicts of the installed packages can be
+ * used for extra speed up. Provide a NULL pointer if you do not
+ * have this information.
+ * Both maps can be created with pool_create_state_maps() or
+ * solver_create_state_maps().
+ *
  * returns:
  * 1:  solvable is installable without any other package changes
  * 0:  solvable is not installable
@@ -431,7 +442,7 @@ solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsm
            }
        }
     }
-  if (0)
+  if (s->repo)
     {
       Repo *installed = 0;
       if (s->obsoletes && s->repo != installed)
@@ -478,6 +489,11 @@ solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsm
   return interesting ? 1 : -1;
 }
 
+/*
+ * different interface for solvable_trivial_installable_map, where
+ * the information about the installed packages is provided
+ * by a queue.
+ */
 int
 solvable_trivial_installable_queue(Solvable *s, Queue *installed)
 {
@@ -499,6 +515,11 @@ solvable_trivial_installable_queue(Solvable *s, Queue *installed)
   return r;
 }
 
+/*
+ * different interface for solvable_trivial_installable_map, where
+ * the information about the installed packages is provided
+ * by a repo containing the installed solvables.
+ */
 int
 solvable_trivial_installable_repo(Solvable *s, Repo *installed)
 {
@@ -516,8 +537,19 @@ solvable_trivial_installable_repo(Solvable *s, Repo *installed)
   return r;
 }
 
+
+/*****************************************************************************/
+
+/*
+ * Create maps containing the state of each solvable. Input is a "installed" queue,
+ * it contains all solvable ids that are considered to be installed.
+ * 
+ * The created maps can be used for solvable_trivial_installable_map(),
+ * pool_calc_duchanges(), pool_calc_installsizechange().
+ *
+ */
 void
-create_trivial_installable_maps(Pool *pool, Queue *installed, Map *installedmap, Map *conflictsmap)
+pool_create_state_maps(Pool *pool, Queue *installed, Map *installedmap, Map *conflictsmap)
 {
   int i;
   Solvable *s;
index c21af31..33f63a8 100644 (file)
@@ -4152,31 +4152,20 @@ solver_solve(Solver *solv, Queue *job)
 void
 solver_calc_duchanges(Solver *solv, DUChanges *mps, int nmps)
 {
-  Pool *pool = solv->pool;
   Map installedmap;
-  Id p;
-  int i;
 
-  map_init(&installedmap, pool->nsolvables);
-  for (i = 1; i < solv->decisionq.count; i++)
-    if ((p = solv->decisionq.elements[i]) > 0)
-      MAPSET(&installedmap, p);
-  pool_calc_duchanges(pool, solv->installed, &installedmap, mps, nmps);
+  solver_create_state_maps(solv, &installedmap, 0);
+  pool_calc_duchanges(solv->pool, solv->installed, &installedmap, mps, nmps);
   map_free(&installedmap);
 }
 
 int
 solver_calc_installsizechange(Solver *solv)
 {
-  Pool *pool = solv->pool;
   Map installedmap;
-  Id p;
-  int i, change;
+  int change;
 
-  map_init(&installedmap, pool->nsolvables);
-  for (i = 1; i < solv->decisionq.count; i++)
-    if ((p = solv->decisionq.elements[i]) > 0)
-      MAPSET(&installedmap, p);
+  solver_create_state_maps(solv, &installedmap, 0);
   change = pool_calc_installsizechange(solv->pool, solv->installed, &installedmap);
   map_free(&installedmap);
   return change;
index 383abe2..f9ef714 100644 (file)
@@ -209,6 +209,7 @@ extern Id solver_next_solutionelement(Solver *solv, Id problem, Id solution, Id
 extern Id solver_findproblemrule(Solver *solv, Id problem);
 extern SolverProbleminfo solver_problemruleinfo(Solver *solv, Queue *job, Id rid, Id *depp, Id *sourcep, Id *targetp);
 
+/* XXX: why is this not static? */
 Id *create_decisions_obsoletesmap(Solver *solv);
 
 /* debug functions, do not use */
@@ -287,5 +288,10 @@ solver_is_enhancing(Solver *solv, Solvable *s)
 void solver_calc_duchanges(Solver *solv, DUChanges *mps, int nmps);
 int solver_calc_installsizechange(Solver *solv);
 
+static inline void
+solver_create_state_maps(Solver *solv, Map *installedmap, Map *conflictsmap)
+{
+  pool_create_state_maps(solv->pool, &solv->decisionq, installedmap, conflictsmap);
+}
 
 #endif /* SATSOLVER_SOLVER_H */