]> Devi Nivas Git - chevron.git/commitdiff
Only define UnclosedSection once.
authorDaniel Morrison <dan@morrison.ph>
Sun, 16 Nov 2014 06:02:03 +0000 (01:02 -0500)
committerDaniel Morrison <dan@morrison.ph>
Sun, 16 Nov 2014 06:02:03 +0000 (01:02 -0500)
If you define things in a loop it slows down. Go figure.

    42% speedup.

entei.py

index 53de592c707459ccb35296a2dbbaebe284abb598..8679773b2a7853ba6041fdfffd19c5ce9ae8039f 100755 (executable)
--- a/entei.py
+++ b/entei.py
@@ -5,6 +5,11 @@ import json
 from sys import argv
 
 
+class UnclosedSection(Exception):
+    """Raised when you have unbalanced section tags"""
+    pass
+
+
 def tokenize(template):
     """Tokenize a mustache template
 
@@ -30,10 +35,6 @@ def tokenize(template):
     the literal itself.
     """
 
-    class UnclosedSection(Exception):
-        """Raised when you have unbalanced section tags"""
-        pass
-
     tag_types = {
         '!': 'comment',
         '#': 'section',