From: Stefan Monnier Date: Mon, 20 Jan 2020 14:50:32 +0000 (-0500) Subject: * lisp/progmodes/cc-cmds.el: Don't use local vars as symbols X-Git-Tag: emacs-28.0.90~7908^2~93 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cdede988b48802c5f2ccce2d38bebcdc4c7dbb05;p=emacs.git * lisp/progmodes/cc-cmds.el: Don't use local vars as symbols (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. --- diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index da614d77b53..a60812230b8 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -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