Pre-compile the regexps in IMAIL-SUMMARY-MATCH-LINE.
authorTaylor R Campbell <campbell@mumble.net>
Sun, 10 Apr 2011 05:01:51 +0000 (05:01 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Sun, 10 Apr 2011 05:01:51 +0000 (05:01 +0000)
This slightly reduces some of the constant factors in the O(n)-time
(!) operation to expand summary buffers...

src/imail/imail-summary.scm

index c7e732e76fcd1798a8c1be65506d5bd6d7db3193..59806b05c4e5eb44d23a354f2274c99f4154b91f 100644 (file)
@@ -686,13 +686,26 @@ SUBJECT is a string of regexps separated by commas."
           (extract-string (re-match-start 1) (re-match-end 1)))
          1)))
 
-(define (imail-summary-match-line mark)
-  (re-match-forward
+(define (make-imail-summary-regexp suffix)
+  (re-compile-pattern
    (string-append
     "[* ][D ][U ][A ][R ][F ] +\\([0-9]+\\)  +\\([0-9.]+[a-zA-Z ]\\)"
-    (if (ref-variable imail-summary-show-date mark)
-       " \\([ 123][0-9] [a-zA-Z]+  \\| +\\)"
-       "  "))
+    suffix)
+   #f))
+
+(define imail-summary-regexp-without-date
+  (make-imail-summary-regexp "  "))
+
+(define imail-summary-regexp-with-date
+  (make-imail-summary-regexp " \\([ 123][0-9] [a-zA-Z]+  \\| +\\)"))
+
+(define (imail-summary-match-line mark)
+  (re-match-forward
+   ;++ This is pretty bogus -- changing the variable will just quietly
+   ;++ break all operations on the summary buffer.
+   (if (ref-variable imail-summary-show-date mark)
+       imail-summary-regexp-with-date
+       imail-summary-regexp-without-date)
    (line-start mark 0)
    (line-end mark 0)
    #f))