Skip to content

Commit da1cf8d

Browse files
committed
Avoid save-match-data for efficiency
The functions markdown-cur-line-blank-p and markdown-new-baseline-p are called repeatedly for font lock and so efficiency is important. We rarely care about preserving the match data when calling these functions, so we no longer guarantee that the match data will be preserved for performance reasons.
1 parent 1f98a34 commit da1cf8d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

markdown-mode.el

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ region to refontify."
15021502
;; If the current line has sufficient indentation, mark out pre block
15031503
;; The opening should be preceded by a blank line.
15041504
((and (looking-at pre-regexp)
1505-
(markdown-prev-line-blank-p))
1505+
(save-match-data (markdown-prev-line-blank-p)))
15061506
(setq open (match-beginning 0))
15071507
(while (and (or (looking-at pre-regexp) (markdown-cur-line-blank-p))
15081508
(not (eobp)))
@@ -2399,10 +2399,9 @@ in XEmacs 21."
23992399

24002400
(defun markdown-cur-line-blank-p ()
24012401
"Return t if the current line is blank and nil otherwise."
2402-
(save-match-data
2403-
(save-excursion
2404-
(beginning-of-line)
2405-
(re-search-forward "^\\s *$" (line-end-position) t))))
2402+
(save-excursion
2403+
(beginning-of-line)
2404+
(re-search-forward "^\\s *$" (line-end-position) t)))
24062405

24072406
(defun markdown-prev-line-blank-p ()
24082407
"Return t if the previous line is blank and nil otherwise.
@@ -2474,12 +2473,11 @@ Return nil if the current line is not the beginning of a list item."
24742473
"Determine if the current line begins a new baseline level."
24752474
(save-excursion
24762475
(beginning-of-line)
2477-
(save-match-data
2478-
(or (looking-at markdown-regex-header)
2479-
(looking-at markdown-regex-hr)
2480-
(and (null (markdown-cur-non-list-indent))
2481-
(= (markdown-cur-line-indent) 0)
2482-
(markdown-prev-line-blank-p))))))
2476+
(or (looking-at markdown-regex-header)
2477+
(looking-at markdown-regex-hr)
2478+
(and (null (markdown-cur-non-list-indent))
2479+
(= (markdown-cur-line-indent) 0)
2480+
(markdown-prev-line-blank-p)))))
24832481

24842482
(defun markdown-search-backward-baseline ()
24852483
"Search backward baseline point with no indentation and not a list item."

0 commit comments

Comments
 (0)