emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/rainbow-delimiters d007f2d797 174/188: Use skip-syntax-for


From: ELPA Syncer
Subject: [nongnu] elpa/rainbow-delimiters d007f2d797 174/188: Use skip-syntax-forward instead of re-search-forward
Date: Sat, 1 Jan 2022 00:59:02 -0500 (EST)

branch: elpa/rainbow-delimiters
commit d007f2d797cd09b3bd15622abb69ba921985181b
Author: Fanael Linithien <fanael4@gmail.com>
Commit: Fanael Linithien <fanael4@gmail.com>

    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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]