Patchwork [05,of,18,helps-py3] changegroup: move from dict() construction to {} literals

login
register
mail settings
Submitter Augie Fackler
Date March 12, 2014, 5:40 p.m.
Message ID <f8d50add83e18d2f078c.1394646039@augie-macbookair>
Download mbox | patch
Permalink /patch/3918/
State Accepted
Commit f8d50add83e18d2f078cb34672cb8198eef91e92
Headers show

Comments

Augie Fackler - March 12, 2014, 5:40 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1394644471 14400
#      Wed Mar 12 13:14:31 2014 -0400
# Node ID f8d50add83e18d2f078cb34672cb8198eef91e92
# Parent  2aafd5854243fda6272085846a435e3412e1b9d5
changegroup: move from dict() construction to {} literals

The latter are both faster and more consistent across Python 2 and 3.

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -173,7 +173,7 @@ 
         if not l:
             return {}
         fname = readexactly(self._stream, l)
-        return dict(filename=fname)
+        return {'filename': fname}
 
     def _deltaheader(self, headertuple, prevnode):
         node, p1, p2, cs = headertuple
@@ -191,8 +191,8 @@ 
         header = struct.unpack(self.deltaheader, headerdata)
         delta = readexactly(self._stream, l - self.deltaheadersize)
         node, p1, p2, deltabase, cs = self._deltaheader(header, prevnode)
-        return dict(node=node, p1=p1, p2=p2, cs=cs,
-                    deltabase=deltabase, delta=delta)
+        return {'node': node, 'p1': p1, 'p2': p2, 'cs': cs,
+                'deltabase': deltabase, 'delta': delta}
 
 class headerlessfixup(object):
     def __init__(self, fh, h):