Anonymous committed 64bd4a6

Cached precompiled regular expression delimiters (speed up User Manual compile
by 250%).

Comments (0)

Files changed (1)
      # Configuration file section name.
         # Configuration parameters.
         self.delimiter=None # Regular expression matching block delimiter.
+        self.delimiter_reo=None # Compiled delimiter.
         self.template=None  # template section entry.
         self.options=()     # options entry list.
         self.presubs=None   # presubs/subs entry list.
         result = False
         if reader.read_next():
-            mo = re.match(self.delimiter,reader.read_next())
+            if not self.delimiter_reo:
+                # Cache compiled delimiter optimization.
+                self.delimiter_reo = re.compile(self.delimiter)
+            mo = self.delimiter_reo.match(reader.read_next())
             if mo:
        = mo
                 result = True
         self.blocks = []        # List of Block objects.
         self.default = None     # Default Block.
-        self.delimiters = None  # Combined tables delimiter regular expression.
+        self.delimiters = None  # Combined delimiters regular expression.
     def load(self,sections):
         """Load block definition from 'sections' dictionary."""
         for k in sections.keys():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.