GNU bug report logs -
#36139
[PATCH] Make better use of the switch op in cond forms
Previous Next
Reported by: Mattias Engdegård <mattiase <at> acm.org>
Date: Sat, 8 Jun 2019 15:16:02 UTC
Severity: wishlist
Tags: patch
Done: Mattias Engdegård <mattiase <at> acm.org>
Bug is archived. No further changes may be made.
Full log
Message #26 received at 36139 <at> debbugs.gnu.org (full text, mbox):
> * lisp/emacs-lisp/bytecomp.el (byte-compile-cond-jump-table-info):
> Expand `memq', `memql' and `member' to their corresponding
> equality tests.
> ---
> lisp/emacs-lisp/bytecomp.el | 46 +++++++++++++++++++++++++------------
> 1 file changed, 31 insertions(+), 15 deletions(-)
>
> diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
> index 38cce14fd6..8f089119de 100644
> --- a/lisp/emacs-lisp/bytecomp.el
> +++ b/lisp/emacs-lisp/bytecomp.el
> @@ -4117,23 +4117,39 @@ byte-compile-cond-jump-table-info
> (byte-compile-cond-vars (cadr condition) (cl-caddr condition))))
> (obj1 (car-safe vars))
> (obj2 (cdr-safe vars))
> - (body (cdr-safe clause)))
> + (body (cdr-safe clause))
> + equality)
> (unless prev-var
> (setq prev-var obj1))
> - (unless prev-test
> - (setq prev-test test))
> - (if (and obj1 (memq test '(eq eql equal))
> - (eq test prev-test)
> - (eq obj1 prev-var))
> - ;; discard duplicate clauses
> - (unless (assoc obj2 cases test)
> - (push (list obj2 body) cases))
> - (if (and (macroexp-const-p condition) condition)
> - (progn (push (list byte-compile--default-val
> - (or body `(,condition)))
> - cases)
> - (throw 'break t))
> - (setq ok nil)
> + (cond
> + ((and obj1 (memq test '(eq eql equal))
> + (eq obj1 prev-var)
> + (or (not prev-test) (eq test prev-test)))
> + (setq prev-test test)
> + ;; discard duplicate clauses
> + (unless (assoc obj2 cases test)
> + (push (list obj2 body) cases)))
> +
> + ((and obj1 (memq test '(memq memql member))
> + (eq obj1 prev-var)
> + (listp obj2)
> + (setq equality (cdr (assq test '((memq . eq)
> + (memql . eql)
> + (member . equal)))))
> + (or (not prev-test) (eq equality prev-test)))
> + (setq prev-test equality)
> + ;; Expand to individual equality tests.
> + (dolist (elem obj2)
> + (unless (assoc elem cases equality)
> + (push (list elem (or body `(',(funcall test elem obj2))))
> + cases))))
> +
> + ((and (macroexp-const-p condition) condition)
> + (push (list byte-compile--default-val
> + (or body `(,condition)))
> + cases)
> + (throw 'break t))
> + (t (setq ok nil)
> (throw 'break nil))))))
> (list (cons prev-test prev-var) (nreverse cases)))))
This patch on its own is problematic because of the code-increase it
can introduce. So I'd suggest merging it with the other one.
Stefan
This bug report was last modified 5 years and 323 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.