diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index f75be3f71ad..f0e543319c3 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -1630,6 +1630,13 @@ byte-optimize-append ;; (append X) -> X ((null newargs) arg) + ;; (append '(X...) ... '(Y...)) -> '(X... Y...) + ((and (eq (car-safe arg) 'quote) + (cl-loop for newarg in newargs + always (and (eq (car-safe newarg) 'quote) + (proper-list-p (cadr newarg))))) + `',(apply #'append (mapcar #'cadr (nreverse (cons arg newargs))))) + ;; (append ... (list Xs...) nil) -> (append ... (list Xs...)) ((and (null arg) (eq (car-safe prev) 'list)) (cons (car form) (nreverse newargs)))