all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: 36139@debbugs.gnu.org
Subject: bug#36139: [PATCH] Make better use of the switch op in cond forms
Date: Tue, 18 Jun 2019 14:48:44 -0400	[thread overview]
Message-ID: <jwvzhme7msv.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> ("Mattias \=\?windows-1252\?Q\?Engdeg\=E5rd\=22's\?\= message of "Sat, 8 Jun 2019 16:40:07 +0200")

> * 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






  parent reply	other threads:[~2019-06-18 18:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-08 14:40 bug#36139: [PATCH] Make better use of the switch op in cond forms Mattias Engdegård
2019-06-08 15:38 ` Drew Adams
2019-06-09  8:38   ` Mattias Engdegård
2019-06-10 15:38   ` npostavs
2019-06-11 11:12     ` Mattias Engdegård
2019-06-11 11:25       ` Noam Postavsky
2019-06-18 12:46         ` Mattias Engdegård
2019-06-18 18:48 ` Stefan Monnier [this message]
2019-06-19  9:25   ` Mattias Engdegård
2019-06-18 18:56 ` Stefan Monnier
2019-06-18 19:03 ` Stefan Monnier
2019-06-19  9:30   ` Mattias Engdegård
2019-06-19 14:03   ` Mattias Engdegård
2019-06-28 20:51     ` Mattias Engdegård
2019-06-18 19:06 ` Stefan Monnier
2019-06-19  9:30   ` Mattias Engdegård
2019-06-18 19:19 ` Stefan Monnier
2019-06-19 10:14   ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvzhme7msv.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=36139@debbugs.gnu.org \
    --cc=mattiase@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.