[Aptitude-svn-commit] r3979 - in branches/aptitude-0.3/aptitude: . src/generic/problemresolver

Daniel Burrows dburrows at costa.debian.org
Mon Aug 29 19:25:48 UTC 2005


Author: dburrows
Date: Mon Aug 29 19:25:45 2005
New Revision: 3979

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/problemresolver/solution.h
Log:
Cache the result of operator* to slightly decrease the time spent in it
(this doesn't reclaim much processing time, but it's such an easy optimization
that I can't justify not doing it).

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Mon Aug 29 19:25:45 2005
@@ -1,5 +1,10 @@
 2005-08-29  Daniel Burrows  <dburrows at debian.org>
 
+	* src/generic/problemresolver/solution.h:
+
+	  Dereferencing a revdep_iterator is a bit expensive; cache the
+	  result of doing so.
+
 	* src/generic/immset.h:
 
 	  Add a convenience routuine to check if a value is in the domain

Modified: branches/aptitude-0.3/aptitude/src/generic/problemresolver/solution.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/problemresolver/solution.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/problemresolver/solution.h	Mon Aug 29 19:25:45 2005
@@ -349,41 +349,57 @@
 	solution_map_wrapper tmpsol(actions);
 
 	// Check reverse deps of the old version
-	for(typename version::revdep_iterator rd=old_version.revdeps_begin();
-	    !rd.end(); ++rd)
-	  if(unresolved_soft_deps.find(*rd) == unresolved_soft_deps.end() &&
-	     (*rd).broken_under(tmpsol))
-	    broken_deps.insert(*rd);
-	  else
-	    broken_deps.erase(*rd);
+	for(typename version::revdep_iterator rdi=old_version.revdeps_begin();
+	    !rdi.end(); ++rdi)
+	  {
+	    dep rd = *rdi;
+
+	    if(unresolved_soft_deps.find(rd) == unresolved_soft_deps.end() &&
+	       (rd).broken_under(tmpsol))
+	      broken_deps.insert(rd);
+	    else
+	      broken_deps.erase(rd);
+	  }
 
 	// Check reverse deps of the new version
 	//
 	// Because reverse deps of a version might be fixed by its
 	// removal, we need to check brokenness and insert or erase as
 	// appropriate.
-	for(typename version::revdep_iterator rd = a.ver.revdeps_begin();
-	    !rd.end(); ++rd)
-	  if(unresolved_soft_deps.find(*rd) == unresolved_soft_deps.end() &&
-	     (*rd).broken_under(tmpsol))
-	    broken_deps.insert(*rd);
-	  else
-	    broken_deps.erase(*rd);
+	for(typename version::revdep_iterator rdi = a.ver.revdeps_begin();
+	    !rdi.end(); ++rdi)
+	  {
+	    dep rd = *rdi;
+
+	    if(unresolved_soft_deps.find(rd) == unresolved_soft_deps.end() &&
+	       (rd).broken_under(tmpsol))
+	      broken_deps.insert(rd);
+	    else
+	      broken_deps.erase(rd);
+	  }
 
 	// Remove all forward deps of the old version (they're
 	// automagically fixed)
 	for(typename version::dep_iterator di=old_version.deps_begin();
 	    !di.end(); ++di)
-	  broken_deps.erase(*di);
+	  {
+	    dep d = *di;
+
+	    broken_deps.erase(d);
+	  }
 
 	// Check forward deps of the new version (no need to erase
 	// non-broken dependencies since they're automatically
 	// non-broken at the start)
 	for(typename version::dep_iterator di=a.ver.deps_begin();
 	    !di.end(); ++di)
-	  if(unresolved_soft_deps.find(*di) == unresolved_soft_deps.end() &&
-	     (*di).broken_under(tmpsol))
-	    broken_deps.insert(*di);
+	  {
+	    dep d = *di;
+
+	    if(unresolved_soft_deps.find(d) == unresolved_soft_deps.end() &&
+	       (d).broken_under(tmpsol))
+	      broken_deps.insert(d);
+	  }
       }
 
     // Add notes about unresolved dependencies



More information about the Aptitude-svn-commit mailing list