manifest: switch add() to heapq.merge (available in Py2.6+)
authortimeless@mozdev.org
Fri, 04 Sep 2015 05:57:58 -0400
changeset 26199 5411059d93f8
parent 26198 1a781a986611
child 26200 461e7b700fdf
manifest: switch add() to heapq.merge (available in Py2.6+)
mercurial/manifest.py
--- a/mercurial/manifest.py	Fri Sep 04 05:54:35 2015 -0400
+++ b/mercurial/manifest.py	Fri Sep 04 05:57:58 2015 -0400
@@ -9,6 +9,7 @@
 import mdiff, parsers, error, revlog, util
 import array, struct
 import os
+import heapq
 
 propertycache = util.propertycache
 
@@ -970,12 +971,9 @@
             # revlog layer.
 
             _checkforbidden(added)
-            # combine the changed lists into one list for sorting
-            work = [(x, False) for x in added]
-            work.extend((x, True) for x in removed)
-            # this could use heapq.merge() (from Python 2.6+) or equivalent
-            # since the lists are already sorted
-            work.sort()
+            # combine the changed lists into one sorted iterator
+            work = heapq.merge([(x, False) for x in added],
+                               [(x, True) for x in removed])
 
             arraytext, deltatext = m.fastdelta(self._mancache[p1][1], work)
             cachedelta = self.rev(p1), deltatext