From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#36139: [PATCH] Make better use of the switch op in cond forms Date: Tue, 18 Jun 2019 14:48:44 -0400 Message-ID: References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="190625"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 36139@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 18 20:50:19 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hdJBR-000nIL-Nd for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Jun 2019 20:50:17 +0200 Original-Received: from localhost ([::1]:32866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdJBI-0004uR-Ib for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Jun 2019 14:50:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32826) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdJBD-0004uJ-SH for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 14:50:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdJBC-0008Ag-O4 for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 14:50:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60279) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hdJBC-0008AO-IX for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 14:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hdJBC-0005K7-Cb for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 14:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Jun 2019 18:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36139 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 36139-submit@debbugs.gnu.org id=B36139.156088374120359 (code B ref 36139); Tue, 18 Jun 2019 18:50:02 +0000 Original-Received: (at 36139) by debbugs.gnu.org; 18 Jun 2019 18:49:01 +0000 Original-Received: from localhost ([127.0.0.1]:45590 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdJAD-0005ID-H9 for submit@debbugs.gnu.org; Tue, 18 Jun 2019 14:49:01 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:19477) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdJAA-0005Hw-GI for 36139@debbugs.gnu.org; Tue, 18 Jun 2019 14:48:59 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id A5371100944; Tue, 18 Jun 2019 14:48:52 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 984AB100737; Tue, 18 Jun 2019 14:48:49 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1560883729; bh=R/tAZTx8nFpYcaXc5q4MJEpbKaQHQp4sdG2thPpyjRc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=bVal+hVMskkuUVhcgSq1PL+b0MN6qJEmvzNVFkqe8YeP0N56U/vhIapA/8o88j1DY RjRb2b5M8JOWNnVqphEIPTjaie6Vg++lHXTFqWBwCkVOc0DkWVH4kLJSX+ZtVVhUiz Tt/USz9yhyHkxAgtRhGSyU7VLBq0YuahG6bHfGr1iaJIdo/VMBXjh+Wpzqlq6k/kYV i+xHak7Ok/kqnFL4GDRRZI/s1I6TweruIh6kYAH4ZJyokoyYCJyFIbZNYf/Dhvqk4o qMN9iISWaBEzDhNHsiXr12TwCQhwZXwamzR4dHtNNILah81XWRgHwQf4uflCdwl1HG pCDhExwGQsRSg== Original-Received: from alfajor (unknown [157.52.10.58]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 06E3E1203AB; Tue, 18 Jun 2019 14:48:47 -0400 (EDT) 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") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:160791 Archived-At: > * 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