Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/
Date: Fri, 31 May 2013 23:52:21
Message-Id: 1370044306.1ea42d5d12ff3f8e59ebcfd12025d401b51894e1.zmedico@gentoo
commit:     1ea42d5d12ff3f8e59ebcfd12025d401b51894e1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri May 31 23:24:32 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri May 31 23:51:46 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1ea42d5d

depgraph: tuple display list, avoid copies

TODO: Optimize _show_merge_list to use reference comparison more
instead of == comparison.

---
 pym/_emerge/Scheduler.py |  2 +-
 pym/_emerge/depgraph.py  | 19 +++++++++++++------
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index 5930550..4e8b223 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -1830,7 +1830,7 @@ class Scheduler(PollScheduler):
 			mylist = mydepgraph.altlist()
 			if mylist:
 				if "--tree" in self.myopts:
-					mylist.reverse()
+					mylist = tuple(reversed(mylist))
 				mydepgraph.display(mylist, favorites=self._favorites)
 
 		if not success:

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 7929a78..9c0a966 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -5704,9 +5704,13 @@ class depgraph(object):
 			except self._serialize_tasks_retry:
 				pass
 
-		retlist = self._dynamic_config._serialized_tasks_cache[:]
+		retlist = self._dynamic_config._serialized_tasks_cache
 		if reversed:
+			# TODO: deprecate the "reversed" parameter (builtin name collision)
+			retlist = list(retlist)
 			retlist.reverse()
+			retlist = tuple(retlist)
+
 		return retlist
 
 	def _implicit_libc_deps(self, mergelist, graph):
@@ -6575,10 +6579,12 @@ class depgraph(object):
 		for blocker in unsolvable_blockers:
 			retlist.append(blocker)
 
+		retlist = tuple(retlist)
+
 		if unsolvable_blockers and \
 			not self._accept_blocker_conflicts():
 			self._dynamic_config._unsatisfied_blockers_for_display = unsolvable_blockers
-			self._dynamic_config._serialized_tasks_cache = retlist[:]
+			self._dynamic_config._serialized_tasks_cache = retlist
 			self._dynamic_config._scheduler_graph = scheduler_graph
 			# Blockers don't trigger the _skip_restart flag, since
 			# backtracking may solve blockers when it solves slot
@@ -6587,7 +6593,7 @@ class depgraph(object):
 
 		if self._dynamic_config._slot_collision_info and \
 			not self._accept_blocker_conflicts():
-			self._dynamic_config._serialized_tasks_cache = retlist[:]
+			self._dynamic_config._serialized_tasks_cache = retlist
 			self._dynamic_config._scheduler_graph = scheduler_graph
 			raise self._unknown_internal_error()
 
@@ -6641,12 +6647,13 @@ class depgraph(object):
 	def _show_merge_list(self):
 		if self._dynamic_config._serialized_tasks_cache is not None and \
 			not (self._dynamic_config._displayed_list is not None and \
-			(self._dynamic_config._displayed_list == self._dynamic_config._serialized_tasks_cache or \
+			(self._dynamic_config._displayed_list is self._dynamic_config._serialized_tasks_cache or \
+			self._dynamic_config._displayed_list == self._dynamic_config._serialized_tasks_cache or \
 			self._dynamic_config._displayed_list == \
 				list(reversed(self._dynamic_config._serialized_tasks_cache)))):
-			display_list = self._dynamic_config._serialized_tasks_cache[:]
+			display_list = self._dynamic_config._serialized_tasks_cache
 			if "--tree" in self._frozen_config.myopts:
-				display_list.reverse()
+				display_list = tuple(reversed(display_list))
 			self.display(display_list)
 
 	def _show_unsatisfied_blockers(self, blockers):