changeset 10064:6f30c35766d6

minirst: don't test regexps twice We know the regexps match since splitparagraphs used them too.
author Martin Geisler <mg@lazybytes.net>
date Sun, 13 Dec 2009 22:37:30 +0100
parents a46478b80ea3
children a1ae0ed78d1a
files mercurial/minirst.py
diffstat 1 files changed, 7 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/minirst.py	Sun Dec 13 19:24:24 2009 +0100
+++ b/mercurial/minirst.py	Sun Dec 13 22:37:30 2009 +0100
@@ -226,20 +226,17 @@
     initindent = subindent = indent
     if block['type'] == 'bullet':
         m = _bulletre.match(block['lines'][0])
-        if m:
-            subindent = indent + m.end() * ' '
+        subindent = indent + m.end() * ' '
     elif block['type'] == 'field':
         m = _fieldre.match(block['lines'][0])
-        if m:
-            key, spaces, rest = m.groups()
-            # Turn ":foo: bar" into "foo   bar".
-            block['lines'][0] = '%s  %s%s' % (key, spaces, rest)
-            subindent = indent + (2 + len(key) + len(spaces)) * ' '
+        key, spaces, rest = m.groups()
+        # Turn ":foo: bar" into "foo   bar".
+        block['lines'][0] = '%s  %s%s' % (key, spaces, rest)
+        subindent = indent + (2 + len(key) + len(spaces)) * ' '
     elif block['type'] == 'option':
         m = _optionre.match(block['lines'][0])
-        if m:
-            option, arg, rest = m.groups()
-            subindent = indent + (len(option) + len(arg)) * ' '
+        option, arg, rest = m.groups()
+        subindent = indent + (len(option) + len(arg)) * ' '
 
     text = ' '.join(map(str.strip, block['lines']))
     return textwrap.fill(text, width=width,