]> git.eshelyaron.com Git - emacs.git/commitdiff
; Optimize shorthand insertion in loaddefs-generate--parse-file
authorJoseph Turner <joseph@ushin.org>
Sat, 3 Feb 2024 14:32:37 +0000 (08:32 -0600)
committerEshel Yaron <me@eshelyaron.com>
Sun, 4 Feb 2024 11:05:27 +0000 (12:05 +0100)
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--parse-file):
Optimize.

(cherry picked from commit f266622cdb34044f364976796a4e7ac003d7a1b3)

lisp/emacs-lisp/loaddefs-gen.el

index 8aacbf406b62152f720038f3603af12d17cebd00..fe29469d08c025fd0855065745b715c95b11808a 100644 (file)
@@ -404,10 +404,13 @@ don't include."
         (save-excursion
           ;; since we're "open-coding" we have to repeat more
           ;; complicated logic in `hack-local-variables'.
-          (when (re-search-forward "read-symbol-shorthands: *" nil t)
-            (let* ((commentless (replace-regexp-in-string
+          (when-let ((beg
+                      (re-search-forward "read-symbol-shorthands: *" nil t)))
+            ;; `read-symbol-shorthands' alist ends with two parens.
+            (let* ((end (re-search-forward ")[;\n\s]*)"))
+                   (commentless (replace-regexp-in-string
                                  "\n\\s-*;+" ""
-                                 (buffer-substring (point) (point-max))))
+                                 (buffer-substring beg end)))
                    (unsorted-shorthands (car (read-from-string commentless))))
               (setq read-symbol-shorthands
                     (sort unsorted-shorthands