changeset 39538:238a1480d7ad

ancestor: use heapreplace() in place of heappop/heappush() This should be slightly faster. Overall perfancestors result:: cpython nginx mercurial ------------- ---------------- ---------------- ---------------- b6db2e80a9ce^ 0.103461 0.006303 0.035716 8eb2145ff0fb 0.192307 (x1.86) 0.012115 (x1.92) 0.052135 (x1.46) this patch 0.139986 (x1.35) 0.006389 (x1.01) 0.037176 (x1.04)
author Yuya Nishihara <yuya@tcha.org>
date Mon, 10 Sep 2018 22:34:19 +0900
parents ca9983c35d89
children 8d8e61df8259
files mercurial/ancestor.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ancestor.py	Tue Sep 11 22:36:51 2018 +0900
+++ b/mercurial/ancestor.py	Mon Sep 10 22:34:19 2018 +0900
@@ -264,6 +264,7 @@
     seen = {nullrev}
     heappush = heapq.heappush
     heappop = heapq.heappop
+    heapreplace = heapq.heapreplace
     see = seen.add
 
     if inclusive:
@@ -294,8 +295,7 @@
             if current - p1 == 1:
                 visit[0] = -p1
             else:
-                heappop(visit)
-                heappush(visit, -p1)
+                heapreplace(visit, -p1)
             see(p1)
         else:
             heappop(visit)