minirst: don't test regexps twice
authorMartin Geisler <mg@lazybytes.net>
Sun, 13 Dec 2009 22:37:30 +0100
changeset 10064 6f30c35766d6
parent 10063 a46478b80ea3
child 10065 a1ae0ed78d1a
minirst: don't test regexps twice We know the regexps match since splitparagraphs used them too.
mercurial/minirst.py
--- 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,