]> git.eshelyaron.com Git - emacs.git/commitdiff
Reinstate defvar-keymap expansion
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 17 Oct 2021 19:29:59 +0000 (21:29 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 17 Oct 2021 19:29:59 +0000 (21:29 +0200)
* lisp/emacs-lisp/byte-opt.el
(byte-optimize-define-keymap--define): Make more robust.

lisp/emacs-lisp/byte-opt.el

index aa57e022c5aa9cccab564eb65b0e46bf370cc256..abfc9b3b316d8a5fc298e206937fc49286b3a34c 100644 (file)
@@ -1237,14 +1237,17 @@ See Info node `(elisp) Integer Basics'."
 
 (defun byte-optimize-define-keymap--define (form)
   "Expand key bindings in FORM."
-  (let ((optimized (byte-optimize-define-keymap (nth 1 form))))
-    (if (eq optimized (nth 1 form))
-        ;; No improvement.
-        form
-      (list (car form) optimized))))
-
-;;(put 'define-keymap 'byte-optimizer #'byte-optimize-define-keymap)
-;;(put 'define-keymap--define 'byte-optimizer #'byte-optimize-define-keymap--define)
+  (if (not (consp (nth 1 form)))
+      form
+    (let ((optimized (byte-optimize-define-keymap (nth 1 form))))
+      (if (eq optimized (nth 1 form))
+          ;; No improvement.
+          form
+        (list (car form) optimized)))))
+
+(put 'define-keymap 'byte-optimizer #'byte-optimize-define-keymap)
+(put 'define-keymap--define 'byte-optimizer
+     #'byte-optimize-define-keymap--define)
 
 ;; I'm not convinced that this is necessary.  Doesn't the optimizer loop
 ;; take care of this? - Jamie