Mercurial > hg
changeset 18752:fabbaa250977
minirst: optimize HTML table generation a bit
avoid a couple of array copies and string interpolations
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Sat, 09 Feb 2013 21:51:21 +0000 |
parents | 13aa81e2fded |
children | 6aca4d1c744e |
files | mercurial/minirst.py |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/minirst.py Sat Feb 09 21:51:21 2013 +0000 +++ b/mercurial/minirst.py Sat Feb 09 21:51:21 2013 +0000 @@ -559,13 +559,17 @@ out.append('<h%d>%s</h%d>\n' % (level, escape(lines[0]), level)) elif btype == 'table': table = b['table'] - t = [] + out.append('<table>\n') for row in table: - l = [] + out.append('<tr>') for v in row: - l.append('<td>%s</td>' % escape(v)) - t.append('<tr>%s</tr>\n' % '\n'.join(l)) - out.append('<table>\n%s</table>\n' % ''.join(t)) + out.append('<td>') + out.append(escape(v)) + out.append('</td>') + out.append('\n') + out.pop() + out.append('</tr>\n') + out.append('</table>\n') elif btype == 'definition': openlist('dl', level) term = escape(lines[0])