aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2020-01-20 09:50:32 -0500
committerStefan Monnier2020-01-20 09:50:32 -0500
commitcdede988b48802c5f2ccce2d38bebcdc4c7dbb05 (patch)
tree3cb23b0992b875bda450904024a55bb0f9326c82
parentb3ad638a60845f17938ff812efcf2b2edfbd8c57 (diff)
downloademacs-cdede988b48802c5f2ccce2d38bebcdc4c7dbb05.tar.gz
emacs-cdede988b48802c5f2ccce2d38bebcdc4c7dbb05.zip
* 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.
-rw-r--r--lisp/progmodes/cc-cmds.el6
1 files changed, 3 insertions, 3 deletions
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."
512 (let ((src (default-value 'post-self-insert-hook))) 512 (let ((src (default-value 'post-self-insert-hook)))
513 (while src 513 (while src
514 (unless (memq (car src) c--unsafe-post-self-insert-hook-functions) 514 (unless (memq (car src) c--unsafe-post-self-insert-hook-functions)
515 (add-hook 'dest (car src) t)) ; Preserve the order of the functions. 515 (push (car src) dest))
516 (setq src (cdr src))))) 516 (setq src (cdr src)))))
517 (t (add-hook 'dest (car src) t))) ; Preserve the order of the functions. 517 (t (push (car src) dest)))
518 (setq src (cdr src))) 518 (setq src (cdr src)))
519 (run-hooks 'dest))) 519 (mapc #'funcall (nreverse dest)))) ; Preserve the order of the functions.
520 520
521(defmacro c--call-post-self-insert-hook-more-safely () 521(defmacro c--call-post-self-insert-hook-more-safely ()
522 ;; Call post-self-insert-hook, if such exists. See comment for 522 ;; Call post-self-insert-hook, if such exists. See comment for