Patchwork [1,of,6,V2] py3: use dict.update() instead of constructing lists and adding them

login
register
mail settings
Submitter Pulkit Goyal
Date June 2, 2017, 8:46 a.m.
Message ID <754e0b7e0ef3c73971b4.1496393166@workspace>
Download mbox | patch
Permalink /patch/21130/
State Accepted
Headers show

Comments

Pulkit Goyal - June 2, 2017, 8:46 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1496259842 -19800
#      Thu Jun 01 01:14:02 2017 +0530
# Node ID 754e0b7e0ef3c73971b44e9c3fb76ab27206893a
# Parent  5492f3cf2e0c0606a83ca239f1ec3fc4d8b4e3f0
py3: use dict.update() instead of constructing lists and adding them

dict.items() returned a list on Python 2 and whereas on Python 3 it returns a
view object. So we required a work around. Using dict.update() is better then
constructing lists as it should save us on gc churns.

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -419,8 +419,10 @@ 
     for f in u2u:
         _checkcopies(c2, c1, f, base, tca, dirtyc2, limit, data2)
 
-    copy = dict(data1['copy'].items() + data2['copy'].items())
-    fullcopy = dict(data1['fullcopy'].items() + data2['fullcopy'].items())
+    copy = dict(data1['copy'])
+    copy.update(data2['copy'])
+    fullcopy = dict(data1['fullcopy'])
+    fullcopy.update(data2['fullcopy'])
 
     if dirtyc1:
         _combinecopies(data2['incomplete'], data1['incomplete'], copy, diverge,