[PATCH] digraph.add: sort priorities with bisect.insort

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] digraph.add: sort priorities with bisect.insort

Zac Medico-2
Reported-by: Sergei Trofimovich <[hidden email]>
---
 pym/portage/util/digraph.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/util/digraph.py b/pym/portage/util/digraph.py
index ba0e81c07..bf20d5d4e 100644
--- a/pym/portage/util/digraph.py
+++ b/pym/portage/util/digraph.py
@@ -5,6 +5,7 @@ from __future__ import unicode_literals
 
 __all__ = ['digraph']
 
+import bisect
 from collections import deque
 import sys
 
@@ -46,8 +47,7 @@ class digraph(object):
  self.nodes[parent][0][node] = priorities
 
  if not priorities or priorities[-1] is not priority:
- priorities.append(priority)
- priorities.sort()
+ bisect.insort(priorities, priority)
 
  def discard(self, node):
  """
--
2.13.0