]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/cc-cmds.el: Don't use local vars as symbols
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 20 Jan 2020 14:50:32 +0000 (09:50 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 20 Jan 2020 14:50:32 +0000 (09:50 -0500)
(c--call-post-self-insert-hook-more-safely-1): Avoid `add-hook` and
`run-hooks` on local vars.  Avoid O(n^2) while we're at it.

lisp/progmodes/cc-cmds.el

index da614d77b536073650958d86013fa72a83bc04cb..a60812230b8c95782763e67a3c15247c431d7704 100644 (file)
@@ -512,11 +512,11 @@ function to control that."
        (let ((src (default-value 'post-self-insert-hook)))
          (while src
            (unless (memq (car src) c--unsafe-post-self-insert-hook-functions)
-             (add-hook 'dest (car src) t)) ; Preserve the order of the functions.
+             (push (car src) dest))
            (setq src (cdr src)))))
-       (t (add-hook 'dest (car src) t))) ; Preserve the order of the functions.
+       (t (push (car src) dest)))
       (setq src (cdr src)))
-    (run-hooks 'dest)))
+    (mapc #'funcall (nreverse dest)))) ; Preserve the order of the functions.
 
 (defmacro c--call-post-self-insert-hook-more-safely ()
   ;; Call post-self-insert-hook, if such exists.  See comment for