branch: elpa/clojure-mode
commit 5325e14cac223e67f42d0835d893bf28a542fda5
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Avoid string allocation in clojure--normal-indent loop
    
    Replace (string-match "[^[:blank:]]" (buffer-substring ...)) with
    a direct buffer scan using skip-chars-backward. The old code
    allocated a fresh string on each iteration of the while loop just
    to check if there are non-blank characters before point on the
    current line.
---
 clojure-mode.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clojure-mode.el b/clojure-mode.el
index 7db2094d10..7d7a9f08c3 100644
--- a/clojure-mode.el
+++ b/clojure-mode.el
@@ -1647,9 +1647,9 @@ accepted by `clojure-indent-style'."
     (if (ignore-errors
           ;; `backward-sexp' until we reach the start of a sexp that is the
           ;; first of its line (the start of the enclosing sexp).
-          (while (string-match
-                  "[^[:blank:]]"
-                  (buffer-substring (line-beginning-position) (point)))
+          (while (save-excursion
+                   (skip-chars-backward " \t")
+                   (not (bolp)))
             (setq last-sexp-start (prog1 (point)
                                     (forward-sexp -1))))
           t)

Reply via email to