minirst: move from dict() construction to {} literals
authorAugie Fackler <raf@durin42.com>
Wed, 12 Mar 2014 13:20:24 -0400
changeset 20682 7f8cbaaa8eea
parent 20681 52e5aca15f0c
child 20683 6cb419dd3703
minirst: move from dict() construction to {} literals The latter are both faster and more consistent across Python 2 and 3.
mercurial/minirst.py
--- a/mercurial/minirst.py	Wed Mar 12 13:20:04 2014 -0400
+++ b/mercurial/minirst.py	Wed Mar 12 13:20:24 2014 -0400
@@ -73,7 +73,7 @@
         if lines:
             indent = min((len(l) - len(l.lstrip())) for l in lines)
             lines = [l[indent:] for l in lines]
-            blocks.append(dict(indent=indent, lines=lines))
+            blocks.append({'indent': indent, 'lines': lines})
     return blocks
 
 def findliteralblocks(blocks):
@@ -174,8 +174,8 @@
                     items = []
                     for j, line in enumerate(lines):
                         if match(lines, j, itemre, singleline):
-                            items.append(dict(type=type, lines=[],
-                                              indent=blocks[i]['indent']))
+                            items.append({'type': type, 'lines': [],
+                                          'indent': blocks[i]['indent']})
                         items[-1]['lines'].append(line)
                     blocks[i:i + 1] = items
                     break
@@ -385,7 +385,7 @@
             # no lines in previous block, do not separate
             i += 1
         else:
-            blocks.insert(i, dict(lines=[''], indent=0, type='margin'))
+            blocks.insert(i, {'lines': [''], 'indent': 0, 'type': 'margin'})
             i += 2
     return blocks