Mercurial > hg-stable
changeset 20682:7f8cbaaa8eea
minirst: move from dict() construction to {} literals
The latter are both faster and more consistent across Python 2 and 3.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Wed, 12 Mar 2014 13:20:24 -0400 |
parents | 52e5aca15f0c |
children | 6cb419dd3703 |
files | mercurial/minirst.py |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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