branch: elpa/rainbow-delimiters
commit d007f2d797cd09b3bd15622abb69ba921985181b
Author: Fanael Linithien <[email protected]>
Commit: Fanael Linithien <[email protected]>
Use skip-syntax-forward instead of re-search-forward
Time needed to do 1000 fontifications of rainbow-delimiters.el:
Before: 3.01 s
After: 2.25 s
---
rainbow-delimiters.el | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/rainbow-delimiters.el b/rainbow-delimiters.el
index 7495d31424..ea160822db 100644
--- a/rainbow-delimiters.el
+++ b/rainbow-delimiters.el
@@ -215,9 +215,6 @@ Returns t if char at loc meets one of the following
conditions:
(t
nil))))
-(defconst rainbow-delimiters--delim-regex "\\s(\\|\\s)"
- "Regex matching all opening and closing delimiters the mode highlights.")
-
;; Main function called by font-lock.
(defun rainbow-delimiters--propertize (end)
"Highlight delimiters in region between point and END.
@@ -226,12 +223,15 @@ Used by font-lock for dynamic highlighting."
(let* ((inhibit-point-motion-hooks t)
(last-ppss-pos (point))
(ppss (syntax-ppss)))
- (while (re-search-forward rainbow-delimiters--delim-regex end t)
- (let* ((delim-pos (match-beginning 0))
+ (while (> end (progn (skip-syntax-forward "^()" end)
+ (point)))
+ (let* ((delim-pos (point))
(delim-syntax (syntax-after delim-pos)))
- (setq ppss (save-excursion
- (parse-partial-sexp last-ppss-pos delim-pos nil nil
ppss)))
+ (setq ppss (parse-partial-sexp last-ppss-pos delim-pos nil nil ppss))
(setq last-ppss-pos delim-pos)
+ ;; `skip-syntax-forward' leaves the point at the delimiter, move past
+ ;; it.
+ (forward-char)
(let ((delim-syntax-code (car delim-syntax)))
(cond
((rainbow-delimiters--char-ineligible-p delim-pos ppss
delim-syntax-code)