From unknown Fri Jun 13 10:33:37 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#36139 <36139@debbugs.gnu.org> To: bug#36139 <36139@debbugs.gnu.org> Subject: Status: [PATCH] Make better use of the switch op in cond forms Reply-To: bug#36139 <36139@debbugs.gnu.org> Date: Fri, 13 Jun 2025 17:33:37 +0000 retitle 36139 [PATCH] Make better use of the switch op in cond forms reassign 36139 emacs submitter 36139 Mattias Engdeg=C3=A5rd severity 36139 wishlist tag 36139 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 08 11:15:50 2019 Received: (at submit) by debbugs.gnu.org; 8 Jun 2019 15:15:50 +0000 Received: from localhost ([127.0.0.1]:53511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hZd4P-0003QB-Cw for submit@debbugs.gnu.org; Sat, 08 Jun 2019 11:15:49 -0400 Received: from lists.gnu.org ([209.51.188.17]:56234) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hZd4O-0003Q4-0d for submit@debbugs.gnu.org; Sat, 08 Jun 2019 11:15:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49805) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZd4D-0007UD-GR for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2019 11:15:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZd43-0004Xq-Pm for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2019 11:15:33 -0400 Received: from mail1423c50.megamailservers.eu ([91.136.14.23]:58010 helo=mail102c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hZd3u-0004Ru-PT for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2019 11:15:21 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1560004810; bh=q7jFxCHF7YGiYJ2CX4fZBdTgsgWfSDK80UCY2jKuCwY=; h=From:Subject:Date:Cc:To:From; b=ICZlOMpNjru7eAhjAW1n/sL+87zypGBstm0GJu0kegpjCv/+HEXsgnL0TYbfs9mrx 2nAojpCqecINUzHH1t3bnrF23rrWSSV5Tvs/n9eT4CtITp/fXug8tbPiOW3jUk9ORQ Y4lHDHvVtEV96pnVio9f8fVDJYUc6jypHvCK341k= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] ([188.150.171.71]) (authenticated bits=0) by mail102c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x58Ee737011987; Sat, 8 Jun 2019 14:40:09 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Content-Type: multipart/mixed; boundary="Apple-Mail=_6425368A-6F6F-40E3-9751-3E52F91F6248" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: [PATCH] Make better use of the switch op in cond forms Message-Id: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> Date: Sat, 8 Jun 2019 16:40:07 +0200 To: bug-gnu-emacs@gnu.org X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0213.5CFBC8CA.0011, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=F7x5iJpN c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=6To3NTLLAc8gFo8t5NcA:9 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19 a=CjuIK1q_8ugA:10 a=E_EwgWnIFQbYCWLjBlUA:9 a=B2y7HmGcmWMA:10 a=mTj2RzUfRsJlQHX1IeMA:9 a=KPFwjdhr0wLR6wY-cI4A:9 a=J5JVcn0FUx--a41e-UEA:9 a=hcRNxtQ6DiqpJ61ql5UA:9 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 91.136.14.23 X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --Apple-Mail=_6425368A-6F6F-40E3-9751-3E52F91F6248 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Currently, `cond' forms will only use a switch op under very specific = circumstances, which limits their potential utility: every condition = must be a scalar comparison (eq, eql or equal) between a variable and a = constant; the same variable and the same test function must be used = everywhere. These restrictions also limit the generation of switch ops = from `pcase' and `cl-case' constructs. In actual `cond' forms, scalar comparisons are mixed with multi-value = ones (memq, memql, member); different comparisons are mixed, since the = type of values can vary at runtime. There are also non-switch = comparisons thrown into the same `cond' for convenience, typically at = the beginning or end. Occasionally, there are even multiple switch-like = sequences against different variables in the same cond. Attached is a set of patches which gradually eliminate many of these = restrictions. Each patch makes a fixed and hopefully easily-reviewed = improvement. Short overview: * 0001-Compile-list-member-functions-in-cond-to-switch.patch Allow memq, memql and member to be used in switch generation, since = these are idiomatically used for multiple values with the same body. = They are also used by `pcase' and `cl-case'. For example, (cond ((eq x 'a) 11) ((memq x '(b c d)) 22)) will generate a single switch as if the code had been (cond ((eq x 'a) 11) ((eq x 'b) 22) ((eq x 'c) 22) ((eq x 'd) 22)) - that is, the byte code for the body (22) will be generated thrice. * 0002-Share-identical-switch-clause-bodies.patch An improvement of the above to share the body byte code between all = values of the same `cond' clause. This means that the switch jump table = is no longer an injective mapping. * 0003-Tighter-pcase-or-pattern-member-function-selection.patch Make `pcase' use the most specific comparison function (memq instead of = memql, etc) in each case, depending on the values. This patch is technically independent of the other ones, but improves = code generation for `pcase'. * 0004-Compile-cond-with-heterogeneous-tests-into-switch.patch Allow switch generation with a mixture of eq, eql, equal, memq, memql = and member. * 0005-Compile-any-subsequence-of-cond-clauses-to-switch.patch Generalise the code to produce switch ops for any switch-like part of a = `cond' form. These switches can use different variables, and there can = be any number of non-switch clauses before, after and between the switch = clauses. Performance: The patch set is loosely monotonous with the assumptions = already present, in the sense that if the current code generator does = not produce slower code in any case, nor is it expected to do so after = the patches have been applied. In practice, micro-benchmarks naturally = show the expected gains, but I haven't found much real-world code that = is easy enough to benchmark. Some unpublished tree-traversal code = improved about 7 %. --Apple-Mail=_6425368A-6F6F-40E3-9751-3E52F91F6248 Content-Disposition: attachment; filename=0001-Compile-list-member-functions-in-cond-to-switch.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Compile-list-member-functions-in-cond-to-switch.patch" Content-Transfer-Encoding: quoted-printable =46rom=207ddfbaf4e50f96d0feb05983c4f1d144af774052=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Tue,=2021=20May=202019=2011:56:14=20+0200=0A= Subject:=20[PATCH=201/5]=20Compile=20list=20member=20functions=20in=20= cond=20to=20switch=0A=0A*=20lisp/emacs-lisp/bytecomp.el=20= (byte-compile-cond-jump-table-info):=0AExpand=20`memq',=20`memql'=20and=20= `member'=20to=20their=20corresponding=0Aequality=20tests.=0A---=0A=20= lisp/emacs-lisp/bytecomp.el=20|=2046=20= +++++++++++++++++++++++++------------=0A=201=20file=20changed,=2031=20= insertions(+),=2015=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/emacs-lisp/bytecomp.el=20b/lisp/emacs-lisp/bytecomp.el=0Aindex=20= 38cce14fd6..8f089119de=20100644=0A---=20a/lisp/emacs-lisp/bytecomp.el=0A= +++=20b/lisp/emacs-lisp/bytecomp.el=0A@@=20-4117,23=20+4117,39=20@@=20= byte-compile-cond-jump-table-info=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(byte-compile-cond-vars=20= (cadr=20condition)=20(cl-caddr=20condition))))=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(obj1=20(car-safe=20vars))=0A=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(obj2=20= (cdr-safe=20vars))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(body=20(cdr-safe=20clause)))=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(body=20(cdr-safe=20clause))=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20equality)=0A=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(unless=20prev-var=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(setq=20prev-var=20obj1))=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(unless=20prev-test=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(setq=20prev-test=20test))=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(if=20(and=20obj1=20(memq=20test=20'(eq=20= eql=20equal))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(eq=20test=20prev-test)=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(eq=20obj1=20prev-var))=0A-=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20discard=20duplicate=20= clauses=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (unless=20(assoc=20obj2=20cases=20test)=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(push=20(list=20obj2=20body)=20cases))=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20(and=20= (macroexp-const-p=20condition)=20condition)=0A-=09=09=20=20=20=20=20= (progn=20(push=20(list=20byte-compile--default-val=0A-=09=09=09=09=09(or=20= body=20`(,condition)))=0A-=09=09=09=09=20=20cases)=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(throw=20= 'break=20t))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (setq=20ok=20nil)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(cond=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((and=20obj1=20(memq=20= test=20'(eq=20eql=20equal))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(eq=20obj1=20prev-var)=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(or=20(not=20prev-test)=20(eq=20= test=20prev-test)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (setq=20prev-test=20test)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20;;=20discard=20duplicate=20clauses=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(unless=20(assoc=20obj2=20cases=20test)=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(push=20(list=20obj2=20= body)=20cases)))=0A+=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ((and=20obj1=20(memq=20test=20'(memq=20memql=20member))=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(eq=20obj1=20= prev-var)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(listp=20obj2)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(setq=20equality=20(cdr=20(assq=20test=20'((memq=20=20=20= .=20eq)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(memql=20=20.=20eql)=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (member=20.=20equal)))))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(or=20(not=20prev-test)=20(eq=20equality=20= prev-test)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20= prev-test=20equality)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20;;=20Expand=20to=20individual=20equality=20tests.=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(dolist=20(elem=20obj2)=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(unless=20(assoc=20elem=20= cases=20equality)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(push=20(list=20elem=20(or=20body=20`(',(funcall=20test=20elem=20= obj2))))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20cases))))=0A+=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20((and=20(macroexp-const-p=20condition)=20condition)=0A+=09=09=20= (push=20(list=20byte-compile--default-val=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(or=20body=20= `(,condition)))=0A+=09=09=20=20=20=20=20=20=20cases)=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(throw=20'break=20t))=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(t=20(setq=20ok=20nil)=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(throw=20'break=20nil))))))=0A= =20=20=20=20=20=20=20=20=20=20(list=20(cons=20prev-test=20prev-var)=20= (nreverse=20cases)))))=0A=20=0A--=20=0A2.20.1=20(Apple=20Git-117)=0A=0A= --Apple-Mail=_6425368A-6F6F-40E3-9751-3E52F91F6248 Content-Disposition: attachment; filename=0002-Share-identical-switch-clause-bodies.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0002-Share-identical-switch-clause-bodies.patch" Content-Transfer-Encoding: quoted-printable =46rom=208e3a4317488940adfd58a43e2f66acafba2ea11f=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Sun,=2026=20May=202019=2014:04:22=20+0200=0A= Subject:=20[PATCH=202/5]=20Share=20identical=20switch=20clause=20bodies=0A= =0A*=20lisp/emacs-lisp/bytecomp.el=20(byte-compile-cond-jump-table-info)=0A= (byte-compile-cond-jump-table):=0ACases=20now=20have=20multiple=20= values.=0A*=20lisp/emacs-lisp/byte-opt.el=20(byte-decompile-bytecode-1)=0A= (byte-optimize-lapcode):=20Don't=20assume=20switch=20hash=20tables=20to=20= be=20injective.=0A---=0A=20lisp/emacs-lisp/byte-opt.el=20|=2021=20= +++++++--------=0A=20lisp/emacs-lisp/bytecomp.el=20|=2051=20= ++++++++++++++++++++++---------------=0A=202=20files=20changed,=2042=20= insertions(+),=2030=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/emacs-lisp/byte-opt.el=20b/lisp/emacs-lisp/byte-opt.el=0Aindex=20= 44cca6136c..b0aa407c8b=20100644=0A---=20a/lisp/emacs-lisp/byte-opt.el=0A= +++=20b/lisp/emacs-lisp/byte-opt.el=0A@@=20-1376,11=20+1376,15=20@@=20= byte-decompile-bytecode-1=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20do=20(setq=20last-constant=20= (copy-hash-table=20e))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20and=20return=20nil)=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20;;=20Replace=20all=20addresses=20with=20TAGs.=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(maphash=20#'(lambda=20= (value=20tag)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(let=20(newtag)=0A-=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20= newtag=20(byte-compile-make-tag))=0A-=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(push=20(cons=20= tag=20newtag)=20tags)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(puthash=20value=20newtag=20= last-constant)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (maphash=20#'(lambda=20(value=20offset)=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(let=20((match=20= (assq=20offset=20tags)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(puthash=20value=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(if=20match=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(cdr=20match)=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(let=20((tag=20(byte-compile-make-tag)))=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(push=20(cons=20offset=20tag)=20= tags)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20tag))=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20last-constant)))=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= last-constant)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20= Replace=20the=20hash=20table=20referenced=20in=20the=20lapcode=20with=20= our=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20modified=20= one.=0A@@=20-1722,13=20+1726,10=20@@=20byte-optimize-lapcode=0A=20=09=09=20= =20=20=20=20keep-going=20t)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20;;=20replace=20references=20to=20tag=20in=20jump=20tables,=20if=20any=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(dolist=20(table=20= byte-compile-jump-tables)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(catch=20'break=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(maphash=20#'(lambda=20(value=20tag)=0A=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (when=20(equal=20tag=20lap0)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20each=20= tag=20occurs=20only=20once=20in=20the=20jump=20table=0A-=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(puthash=20value=20lap1=20table)=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (throw=20'break=20nil)))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20table))))=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(puthash=20value=20lap1=20table)))=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20table)))=0A=20=09=20= =20=20=20=20=20;;=0A=20=09=20=20=20=20=20=20;;=20unused-TAG:=20-->=20= =0A=20=09=20=20=20=20=20=20;;=0Adiff=20--git=20= a/lisp/emacs-lisp/bytecomp.el=20b/lisp/emacs-lisp/bytecomp.el=0Aindex=20= 8f089119de..5930386166=20100644=0A---=20a/lisp/emacs-lisp/bytecomp.el=0A= +++=20b/lisp/emacs-lisp/bytecomp.el=0A@@=20-4105,9=20+4105,10=20@@=20= byte-compile-cond-jump-table-info=0A=20TEST=20and=20VAR=20are=20the=20= same=20throughout=20all=20conditions.=0A=20VALUE=20satisfies=20= `macroexp-const-p'.=0A=20=0A-Return=20a=20list=20of=20the=20form=20= ((TEST=20.=20VAR)=20=20((VALUE=20BODY)=20...))"=0A+Return=20a=20list=20= of=20the=20form=20((TEST=20.=20VAR)=20=20((VALUES=20BODY)=20...))"=0A=20=20= =20(let=20((cases=20'())=0A=20=20=20=20=20=20=20=20=20(ok=20t)=0A+=20=20=20= =20=20=20=20=20(all-keys=20nil)=0A=20=20=20=20=20=20=20=20=20prev-var=20= prev-test)=0A=20=20=20=20=20(and=20(catch=20'break=0A=20=20=20=20=20=20=20= =20=20=20=20=20(dolist=20(clause=20(cdr=20clauses)=20ok)=0A@@=20-4126,23=20= +4127,30=20@@=20byte-compile-cond-jump-table-info=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(eq=20obj1=20prev-var)=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(or=20= (not=20prev-test)=20(eq=20test=20prev-test)))=0A=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(setq=20prev-test=20test)=0A-=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20;;=20discard=20duplicate=20clauses=0A-=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(unless=20(assoc=20obj2=20= cases=20test)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (push=20(list=20obj2=20body)=20cases)))=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20;;=20Discard=20values=20already=20tested=20for.=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(unless=20(member=20obj2=20= all-keys)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (push=20obj2=20all-keys)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(push=20(list=20(list=20obj2)=20body)=20cases)))=0A=20=0A=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((and=20obj1=20(memq=20test=20= '(memq=20memql=20member))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(eq=20obj1=20prev-var)=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(listp=20obj2)=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20Require=20a=20= non-empty=20body,=20since=20the=20member=20function=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20value=20depends=20= on=20the=20switch=20argument.=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20body=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(setq=20equality=20(cdr=20(assq=20test=20= '((memq=20=20=20.=20eq)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(memql=20=20.=20eql)=0A=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(member=20.=20equal)))))=0A=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(or=20(not=20prev-test)=20(eq=20= equality=20prev-test)))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(setq=20prev-test=20equality)=0A-=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20;;=20Expand=20to=20individual=20equality=20tests.=0A-=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(dolist=20(elem=20obj2)=0A-=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(unless=20(assoc=20= elem=20cases=20equality)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(push=20(list=20elem=20(or=20body=20`(',(funcall=20= test=20elem=20obj2))))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20cases))))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(let=20((vals=20nil))=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20;;=20Discard=20values=20already=20= tested=20for.=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (dolist=20(elem=20obj2)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(unless=20(funcall=20test=20elem=20all-keys)=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(push=20elem=20= vals)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (when=20vals=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(setq=20all-keys=20(append=20vals=20all-keys))=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(push=20(list=20vals=20= body)=20cases))))=0A=20=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20((and=20(macroexp-const-p=20condition)=20condition)=0A=20=09=09=20= (push=20(list=20byte-compile--default-val=0A@@=20-4158,18=20+4166,20=20= @@=20byte-compile-cond-jump-table=0A=20=20=20=20=20=20=20=20=20=20(test=20= (caar=20table-info))=0A=20=20=20=20=20=20=20=20=20=20(var=20(cdar=20= table-info))=0A=20=20=20=20=20=20=20=20=20=20(cases=20(cadr=20= table-info))=0A-=20=20=20=20=20=20=20=20=20jump-table=20test-obj=20body=20= tag=20donetag=20default-tag=20default-case)=0A+=20=20=20=20=20=20=20=20=20= jump-table=20test-objects=20body=20tag=20donetag=20default-tag=20= default-case)=0A=20=20=20=20=20(when=20(and=20cases=20(not=20(=3D=20= (length=20cases)=201)))=0A=20=20=20=20=20=20=20;;=20TODO:=20Once=20= :linear-search=20is=20implemented=20for=20`make-hash-table'=0A=20=20=20=20= =20=20=20;;=20set=20it=20to=20`t'=20for=20cond=20forms=20with=20a=20= small=20number=20of=20cases.=0A-=20=20=20=20=20=20(setq=20jump-table=20= (make-hash-table=0A-=09=09=09:test=20test=0A-=09=09=09:purecopy=20t=0A-=09= =09=09:size=20(if=20(assq=20byte-compile--default-val=20cases)=0A-=09=09=09= =09=20=20(1-=20(length=20cases))=0A-=09=09=09=09(length=20cases)))=0A-=20= =20=20=20=20=20=20=20=20=20=20=20default-tag=20(byte-compile-make-tag)=0A= -=20=20=20=20=20=20=20=20=20=20=20=20donetag=20(byte-compile-make-tag))=0A= +=20=20=20=20=20=20(let=20((nvalues=20(apply=20#'+=20(mapcar=20(lambda=20= (case)=20(length=20(car=20case)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20cases))))=0A+=20=20=20=20=20=20=20=20(setq=20jump-table=20= (make-hash-table=0A+=09=09=09=20=20:test=20test=0A+=09=09=09=20=20= :purecopy=20t=0A+=09=09=09=20=20:size=20(if=20(assq=20= byte-compile--default-val=20cases)=0A+=09=09=09=09=20=20=20=20(1-=20= nvalues)=0A+=09=09=09=09=20=20nvalues))))=0A+=20=20=20=20=20=20(setq=20= default-tag=20(byte-compile-make-tag))=0A+=20=20=20=20=20=20(setq=20= donetag=20(byte-compile-make-tag))=0A=20=20=20=20=20=20=20;;=20The=20= structure=20of=20byte-switch=20code:=0A=20=20=20=20=20=20=20;;=0A=20=20=20= =20=20=20=20;;=20varref=20var=0A@@=20-4206,10=20+4216,11=20@@=20= byte-compile-cond-jump-table=0A=20=0A=20=20=20=20=20=20=20(dolist=20= (case=20cases)=0A=20=20=20=20=20=20=20=20=20(setq=20tag=20= (byte-compile-make-tag)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20= test-obj=20(nth=200=20case)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= test-objects=20(nth=200=20case)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20body=20(nth=201=20case))=0A=20=20=20=20=20=20=20=20=20= (byte-compile-out-tag=20tag)=0A-=20=20=20=20=20=20=20=20(puthash=20= test-obj=20tag=20jump-table)=0A+=20=20=20=20=20=20=20=20(dolist=20(value=20= test-objects)=0A+=20=20=20=20=20=20=20=20=20=20(puthash=20value=20tag=20= jump-table))=0A=20=0A=20=20=20=20=20=20=20=20=20(let=20= ((byte-compile-depth=20byte-compile-depth)=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(init-depth=20byte-compile-depth))=0A--=20=0A2.20.1=20= (Apple=20Git-117)=0A=0A= --Apple-Mail=_6425368A-6F6F-40E3-9751-3E52F91F6248 Content-Disposition: attachment; filename=0003-Tighter-pcase-or-pattern-member-function-selection.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0003-Tighter-pcase-or-pattern-member-function-selection.patch" Content-Transfer-Encoding: quoted-printable =46rom=2016e72d20f6a13ff626721ae55b66e1c3848a5813=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Tue,=2021=20May=202019=2012:19:38=20+0200=0A= Subject:=20[PATCH=203/5]=20Tighter=20pcase=20or-pattern=20member=20= function=20selection=0A=0A*=20lisp/emacs-lisp/pcase.el=20(pcase--u1):=0A= Use=20the=20most=20specific=20of=20`memq',=20`memql'=20and=20`member'=20= in=20or-patterns=0Awith=20constant=20cases.=20=20This=20improves=20= performance=20and=20may=20help=20the=20byte-code=0Acompiler=20generate=20= a=20switch.=0A*=20test/lisp/emacs-lisp/pcase-tests.el=20= (pcase-tests-member):=0AAdd=20mixed-type=20or-pattern=20test=20cases.=0A= ---=0A=20lisp/emacs-lisp/pcase.el=20=20=20=20=20=20=20=20=20=20=20=20|=20= 15=20++++++++-------=0A=20test/lisp/emacs-lisp/pcase-tests.el=20|=20=206=20= ++++--=0A=202=20files=20changed,=2012=20insertions(+),=209=20= deletions(-)=0A=0Adiff=20--git=20a/lisp/emacs-lisp/pcase.el=20= b/lisp/emacs-lisp/pcase.el=0Aindex=20a644453a94..ae2cf8eb02=20100644=0A= ---=20a/lisp/emacs-lisp/pcase.el=0A+++=20b/lisp/emacs-lisp/pcase.el=0A@@=20= -785,25=20+785,26=20@@=20pcase--u1=0A=20=20=20=20((eq=20'or=20(caar=20= matches))=0A=20=20=20=20=20(let*=20((alts=20(cdar=20matches))=0A=20=20=20= =20=20=20=20=20=20=20=20=20(var=20(if=20(eq=20(caar=20alts)=20'match)=20= (cadr=20(car=20alts))))=0A-=20=20=20=20=20=20=20=20=20=20=20(simples=20= '())=20(others=20'())=20(memql-ok=20t))=0A+=20=20=20=20=20=20=20=20=20=20= =20(simples=20'())=20(others=20'())=20(mem-fun=20'memq))=0A=20=20=20=20=20= =20=20(when=20var=0A=20=20=20=20=20=20=20=20=20(dolist=20(alt=20alts)=0A=20= =20=20=20=20=20=20=20=20=20=20(if=20(and=20(eq=20(car=20alt)=20'match)=20= (eq=20var=20(cadr=20alt))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(let=20((upat=20(cddr=20alt)))=0A=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(eq=20(car-safe=20upat)=20= 'quote)))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(let=20((val=20= (cadr=20(cddr=20alt))))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (unless=20(or=20(integerp=20val)=20(symbolp=20val))=0A-=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(setq=20memql-ok=20nil))=0A-=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(push=20(cadr=20(cddr=20alt))=20= simples))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(cond=20= ((integerp=20val)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(when=20(eq=20mem-fun=20'memq)=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20mem-fun=20= 'memql)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20((not=20(symbolp=20val))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(setq=20mem-fun=20'member)))=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(push=20val=20simples))=0A=20=20=20=20= =20=20=20=20=20=20=20=20=20(push=20alt=20others))))=0A=20=20=20=20=20=20=20= (cond=0A=20=20=20=20=20=20=20=20((null=20alts)=20(error=20"Please=20= avoid=20it")=20(pcase--u=20rest))=0A=20=20=20=20=20=20=20=20;;=20Yes,=20= we=20can=20use=20`memql'=20(or=20`member')!=0A=20=20=20=20=20=20=20=20= ((>=20(length=20simples)=201)=0A=20=20=20=20=20=20=20=20=20(pcase--u1=20= (cons=20`(match=20,var=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20.=20(pred=20= (pcase--flip=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ,(if=20memql-ok=20#'memql=20#'member)=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20',simples)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20.=20(pred=20= (pcase--flip=20,mem-fun=20',simples)))=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(cdr=20matches))=0A=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20code=20vars=0A=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20(null=20others)=20= rest=0Adiff=20--git=20a/test/lisp/emacs-lisp/pcase-tests.el=20= b/test/lisp/emacs-lisp/pcase-tests.el=0Aindex=20af8c9a3f3c..e8c0b8219c=20= 100644=0A---=20a/test/lisp/emacs-lisp/pcase-tests.el=0A+++=20= b/test/lisp/emacs-lisp/pcase-tests.el=0A@@=20-51,9=20+51,11=20@@=20= pcase-tests-grep=0A=20=0A=20(ert-deftest=20pcase-tests-member=20()=0A=20=20= =20(should=20(pcase-tests-grep=0A-=20=20=20=20=20=20=20=20=20=20=20= 'memql=20(macroexpand-all=20'(pcase=20x=20((or=201=202=203)=20body)))))=0A= +=20=20=20=20=20=20=20=20=20=20=20'memq=20(macroexpand-all=20'(pcase=20x=20= ((or=20'a=20'b=20'c)=20body)))))=0A=20=20=20(should=20(pcase-tests-grep=0A= -=20=20=20=20=20=20=20=20=20=20=20'member=20(macroexpand-all=20'(pcase=20= x=20((or=20"a"=202=203)=20body)))))=0A+=20=20=20=20=20=20=20=20=20=20=20= 'memql=20(macroexpand-all=20'(pcase=20x=20((or=201=202=203=20'a)=20= body)))))=0A+=20=20(should=20(pcase-tests-grep=0A+=20=20=20=20=20=20=20=20= =20=20=20'member=20(macroexpand-all=20'(pcase=20x=20((or=20"a"=202=203=20= 'a)=20body)))))=0A=20=20=20(should-not=20(pcase-tests-grep=0A=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20'memq=20(macroexpand-all=20'(pcase=20= x=20((or=20"a"=202=203)=20body)))))=0A=20=20=20(should-not=20= (pcase-tests-grep=0A--=20=0A2.20.1=20(Apple=20Git-117)=0A=0A= --Apple-Mail=_6425368A-6F6F-40E3-9751-3E52F91F6248 Content-Disposition: attachment; filename=0004-Compile-cond-with-heterogeneous-tests-into-switch.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0004-Compile-cond-with-heterogeneous-tests-into-switch.patch" Content-Transfer-Encoding: quoted-printable =46rom=20876f73720ef3274352cf707dbeb1cbb02817cd03=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Wed,=2022=20May=202019=2012:36:03=20+0200=0A= Subject:=20[PATCH=204/5]=20Compile=20cond=20with=20heterogeneous=20tests=20= into=20switch=0A=0AAllow=20any=20mixture=20of=20`eq',=20`eql'=20and=20= `equal',=20`memq',=20`memql'=20and=0A`member'=20in=20a=20switch-like=20= `cond'=20to=20be=20compiled=20into=20a=20single=20switch.=0A=0A*=20= lisp/emacs-lisp/bytecomp.el=20(byte-compile--common-test):=20New.=0A= (byte-compile-cond-jump-table-info):=20Use=20most=20specific=20common=20= test.=0A*=20test/lisp/emacs-lisp/bytecomp-tests.el=20= (byte-opt-testsuite-arith-data):=0AAdd=20test=20cases=20for=20= multi-value=20clause=20cond=20forms.=0A---=0A=20= lisp/emacs-lisp/bytecomp.el=20=20=20=20=20=20=20=20=20=20=20=20|=2029=20= +++++++++++++++-----------=0A=20test/lisp/emacs-lisp/bytecomp-tests.el=20= |=2025=20+++++++++++++++++++++-=0A=202=20files=20changed,=2041=20= insertions(+),=2013=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/emacs-lisp/bytecomp.el=20b/lisp/emacs-lisp/bytecomp.el=0Aindex=20= 5930386166..5ee5ceac18=20100644=0A---=20a/lisp/emacs-lisp/bytecomp.el=0A= +++=20b/lisp/emacs-lisp/bytecomp.el=0A@@=20-4098,6=20+4098,12=20@@=20= byte-compile-cond-vars=0A=20=0A=20(defconst=20byte-compile--default-val=20= (cons=20nil=20nil)=20"A=20unique=20object.")=0A=20=0A+(defun=20= byte-compile--common-test=20(test-1=20test-2)=0A+=20=20"Most=20specific=20= common=20test=20of=20`eq',=20`eql'=20and=20`equal'"=0A+=20=20(cond=20= ((or=20(eq=20test-1=20'equal)=20(eq=20test-2=20'equal))=20'equal)=0A+=20=20= =20=20=20=20=20=20((or=20(eq=20test-1=20'eql)=20=20=20(eq=20test-2=20= 'eql))=20=20=20'eql)=0A+=20=20=20=20=20=20=20=20(t=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20'eq)))=0A+=0A=20(defun=20= byte-compile-cond-jump-table-info=20(clauses)=0A=20=20=20"If=20CLAUSES=20= is=20a=20`cond'=20form=20where:=0A=20The=20condition=20for=20each=20= clause=20is=20of=20the=20form=20(TEST=20VAR=20VALUE).=0A@@=20-4109,7=20= +4115,8=20@@=20byte-compile-cond-jump-table-info=0A=20=20=20(let=20= ((cases=20'())=0A=20=20=20=20=20=20=20=20=20(ok=20t)=0A=20=20=20=20=20=20= =20=20=20(all-keys=20nil)=0A-=20=20=20=20=20=20=20=20prev-var=20= prev-test)=0A+=20=20=20=20=20=20=20=20(prev-test=20'eq)=0A+=20=20=20=20=20= =20=20=20prev-var)=0A=20=20=20=20=20(and=20(catch=20'break=0A=20=20=20=20= =20=20=20=20=20=20=20=20(dolist=20(clause=20(cdr=20clauses)=20ok)=0A=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(let*=20((condition=20(car=20= clause))=0A@@=20-4118,15=20+4125,13=20@@=20= byte-compile-cond-jump-table-info=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(byte-compile-cond-vars=20= (cadr=20condition)=20(cl-caddr=20condition))))=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(obj1=20(car-safe=20vars))=0A=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(obj2=20= (cdr-safe=20vars))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(body=20(cdr-safe=20clause))=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20equality)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(body=20(cdr-safe=20clause)))=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(unless=20prev-var=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(setq=20prev-var=20obj1))=0A=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(cond=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20((and=20obj1=20(memq=20test=20'(eq=20eql=20equal))=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(eq=20= obj1=20prev-var)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(or=20(not=20prev-test)=20(eq=20test=20prev-test)))=0A-=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20prev-test=20test)=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(eq=20= obj1=20prev-var))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (setq=20prev-test=20(byte-compile--common-test=20prev-test=20test))=0A=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20Discard=20values=20= already=20tested=20for.=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(unless=20(member=20obj2=20all-keys)=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(push=20obj2=20all-keys)=0A@@=20-4137,12=20= +4142,12=20@@=20byte-compile-cond-jump-table-info=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(listp=20obj2)=0A=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20Require=20= a=20non-empty=20body,=20since=20the=20member=20function=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20value=20= depends=20on=20the=20switch=20argument.=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20body=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(setq=20equality=20(cdr=20(assq=20= test=20'((memq=20=20=20.=20eq)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(memql=20=20.=20eql)=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(member=20.=20equal)))))=0A-=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(or=20(not=20prev-test)=20(eq=20= equality=20prev-test)))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(setq=20prev-test=20equality)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20body)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(setq=20prev-test=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(byte-compile--common-test=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20prev-test=20(cdr=20= (assq=20test=20'((memq=20=20=20.=20eq)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(memql=20=20.=20eql)=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(member=20.=20equal))))))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(let=20((vals=20nil))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20;;=20Discard=20values=20already=20tested=20for.=0A=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(dolist=20(elem=20= obj2)=0Adiff=20--git=20a/test/lisp/emacs-lisp/bytecomp-tests.el=20= b/test/lisp/emacs-lisp/bytecomp-tests.el=0Aindex=20= f45c9209c1..87f2c13bf7=20100644=0A---=20= a/test/lisp/emacs-lisp/bytecomp-tests.el=0A+++=20= b/test/lisp/emacs-lisp/bytecomp-tests.el=0A@@=20-311,7=20+311,30=20@@=20= byte-opt-testsuite-arith-data=0A=20=20=20=20=20(let=20((x=20"a"))=20= (cond=20((equal=20x=20"a")=20'correct)=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((equal=20x=20"b")=20= 'incorrect)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20((equal=20x=20"a")=20'incorrect)=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((equal=20x=20"c")=20= 'incorrect))))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20((equal=20x=20"c")=20'incorrect)))=0A+=20=20=20=20;;=20= Multi-value=20clauses=0A+=20=20=20=20(mapcar=20(lambda=20(x)=20(cond=20= ((eq=20x=20'a)=2011)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20((memq=20x=20'(b=20a=20c=20d))=20= 22)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20((eq=20x=20'c)=2033)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((eq=20x=20= 'e)=2044)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20((memq=20x=20'(d=20f=20g))=2055)=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(t=2099)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20'(a=20b=20c=20d=20= e=20f=20g=20h))=0A+=20=20=20=20(mapcar=20(lambda=20(x)=20(cond=20((eql=20= x=201)=2011)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20((memq=20x=20'(a=20b=20c))=2022)=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20((memql=20x=20'(2=201=204=201e-3))=2033)=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ((eq=20x=20'd)=2044)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20((eql=20x=20= #x10000000000000000))))=0A+=20=20=20=20=20=20=20=20=20=20=20=20'(1=202=20= 4=201e-3=20a=20b=20c=20d=201.0=20#x10000000000000000))=0A+=20=20=20=20= (mapcar=20(lambda=20(x)=20(cond=20((eq=20x=20'a)=2011)=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ((memq=20x=20'(b=20d))=2022)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((equal=20x=20'(a=20.=20= b))=2033)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20((member=20x=20'(b=20c=201.5=202.5=20"X"=20= (d)))=2044)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20((eql=20x=203.14)=2055)=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ((memql=20x=20'(9=200.5=201.5=20q))=2066)=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(t=2099)))=0A= +=20=20=20=20=20=20=20=20=20=20=20=20'(a=20b=20c=20d=20(d)=20(a=20.=20b)=20= "X"=200.5=201.5=203.14=209=209.0))=0A+=20=20=20=20)=0A=20=20=20"List=20= of=20expression=20for=20test.=0A=20Each=20element=20will=20be=20executed=20= by=20interpreter=20and=20with=0A=20bytecompiled=20code,=20and=20their=20= results=20compared.")=0A--=20=0A2.20.1=20(Apple=20Git-117)=0A=0A= --Apple-Mail=_6425368A-6F6F-40E3-9751-3E52F91F6248 Content-Disposition: attachment; filename=0005-Compile-any-subsequence-of-cond-clauses-to-switch.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0005-Compile-any-subsequence-of-cond-clauses-to-switch.patch" Content-Transfer-Encoding: quoted-printable =46rom=209822f95ca1c3c92b2097c01b3f209d0155284be2=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Fri,=207=20Jun=202019=2017:04:10=20+0200=0A= Subject:=20[PATCH=205/5]=20Compile=20any=20subsequence=20of=20`cond'=20= clauses=20to=20switch=0A=0AA=20single=20`cond'=20form=20can=20how=20be=20= compiled=20to=20any=20number=20of=20switch=20ops,=0Ainterspersed=20with=20= non-switch=20conditions=20in=20arbitrary=20ways.=20=20Previously,=0A= switch=20ops=20would=20only=20be=20used=20for=20whole=20`cond'=20forms=20= containing=20no=0Aother=20tests.=0A=0A*=20lisp/emacs-lisp/bytecomp.el=20= (byte-compile--cond-vars):=0ARename=20from=20`byte-compile-cond-vars'.=0A= (byte-compile--default-val):=20Remove.=0A= (byte-compile--cond-switch-prefix):=0AReplace=20= `byte-compile-cond-jump-table-info';=20now=20also=20returns=0Atrailing=20= non-switch=20clauses.=0A(byte-compile-cond-jump-table):=20New=20= arguments;=20no=20longer=20compiles=0Athe=20default=20case.=0A= (byte-compile-cond):=20Look=20for=20and=20compile=20switches=20at=20any=20= place=20in=20the=0Alist=20of=20clauses.=0A*=20= test/lisp/emacs-lisp/bytecomp-tests.el=20= (byte-opt-testsuite-arith-data):=0AAdd=20test=20expression.=0A---=0A=20= lisp/emacs-lisp/bytecomp.el=20=20=20=20=20=20=20=20=20=20=20=20|=20339=20= ++++++++++++-------------=0A=20test/lisp/emacs-lisp/bytecomp-tests.el=20= |=20=2015=20+-=0A=202=20files=20changed,=20173=20insertions(+),=20181=20= deletions(-)=0A=0Adiff=20--git=20a/lisp/emacs-lisp/bytecomp.el=20= b/lisp/emacs-lisp/bytecomp.el=0Aindex=205ee5ceac18..82e47794e3=20100644=0A= ---=20a/lisp/emacs-lisp/bytecomp.el=0A+++=20= b/lisp/emacs-lisp/bytecomp.el=0A@@=20-4088,7=20+4088,7=20@@=20= byte-compile-if=0A=20=09(byte-compile-out-tag=20donetag))))=0A=20=20=20= (setq=20byte-compile--for-effect=20nil))=0A=20=0A-(defun=20= byte-compile-cond-vars=20(obj1=20obj2)=0A+(defun=20= byte-compile--cond-vars=20(obj1=20obj2)=0A=20=20=20;;=20We=20make=20sure=20= that=20of=20OBJ1=20and=20OBJ2,=20one=20of=20them=20is=20a=20symbol,=0A=20= =20=20;;=20and=20the=20other=20is=20a=20constant=20expression=20whose=20= value=20can=20be=0A=20=20=20;;=20compared=20with=20`eq'=20(with=20= `macroexp-const-p').=0A@@=20-4096,193=20+4096,172=20@@=20= byte-compile-cond-vars=0A=20=20=20=20(and=20(symbolp=20obj1)=20= (macroexp-const-p=20obj2)=20(cons=20obj1=20(eval=20obj2)))=0A=20=20=20=20= (and=20(symbolp=20obj2)=20(macroexp-const-p=20obj1)=20(cons=20obj2=20= (eval=20obj1)))))=0A=20=0A-(defconst=20byte-compile--default-val=20(cons=20= nil=20nil)=20"A=20unique=20object.")=0A-=0A=20(defun=20= byte-compile--common-test=20(test-1=20test-2)=0A=20=20=20"Most=20= specific=20common=20test=20of=20`eq',=20`eql'=20and=20`equal'"=0A=20=20=20= (cond=20((or=20(eq=20test-1=20'equal)=20(eq=20test-2=20'equal))=20= 'equal)=0A=20=20=20=20=20=20=20=20=20((or=20(eq=20test-1=20'eql)=20=20=20= (eq=20test-2=20'eql))=20=20=20'eql)=0A=20=20=20=20=20=20=20=20=20(t=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20'eq)))=0A=20=0A-(defun=20= byte-compile-cond-jump-table-info=20(clauses)=0A-=20=20"If=20CLAUSES=20= is=20a=20`cond'=20form=20where:=0A-The=20condition=20for=20each=20clause=20= is=20of=20the=20form=20(TEST=20VAR=20VALUE).=0A-VAR=20is=20a=20variable.=0A= -TEST=20and=20VAR=20are=20the=20same=20throughout=20all=20conditions.=0A= -VALUE=20satisfies=20`macroexp-const-p'.=0A-=0A-Return=20a=20list=20of=20= the=20form=20((TEST=20.=20VAR)=20=20((VALUES=20BODY)=20...))"=0A-=20=20= (let=20((cases=20'())=0A-=20=20=20=20=20=20=20=20(ok=20t)=0A-=20=20=20=20= =20=20=20=20(all-keys=20nil)=0A-=20=20=20=20=20=20=20=20(prev-test=20= 'eq)=0A-=20=20=20=20=20=20=20=20prev-var)=0A-=20=20=20=20(and=20(catch=20= 'break=0A-=20=20=20=20=20=20=20=20=20=20=20(dolist=20(clause=20(cdr=20= clauses)=20ok)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20(let*=20= ((condition=20(car=20clause))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(test=20(car-safe=20condition))=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(vars=20(when=20(consp=20= condition)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(byte-compile-cond-vars=20(cadr=20condition)=20= (cl-caddr=20condition))))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(obj1=20(car-safe=20vars))=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(obj2=20(cdr-safe=20vars))=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(body=20(cdr-safe=20= clause)))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(unless=20= prev-var=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20= prev-var=20obj1))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(cond=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((and=20obj1=20(memq=20= test=20'(eq=20eql=20equal))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(eq=20obj1=20prev-var))=0A-=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(setq=20prev-test=20= (byte-compile--common-test=20prev-test=20test))=0A-=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20;;=20Discard=20values=20already=20tested=20= for.=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(unless=20= (member=20obj2=20all-keys)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(push=20obj2=20all-keys)=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(push=20(list=20(list=20obj2)=20body)=20cases)))=0A= -=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((and=20obj1=20= (memq=20test=20'(memq=20memql=20member))=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(eq=20obj1=20prev-var)=0A-=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(listp=20obj2)=0A-=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20= Require=20a=20non-empty=20body,=20since=20the=20member=20function=0A-=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20value=20= depends=20on=20the=20switch=20argument.=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20body)=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(setq=20prev-test=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(byte-compile--common-test=0A-=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20prev-test=20= (cdr=20(assq=20test=20'((memq=20=20=20.=20eq)=0A-=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(memql=20=20.=20= eql)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(member=20.=20equal))))))=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(let=20((vals=20nil))=0A-=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20;;=20Discard=20values=20already=20tested=20= for.=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(dolist=20= (elem=20obj2)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(unless=20(funcall=20test=20elem=20all-keys)=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(push=20elem=20vals)))=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(when=20vals=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20= all-keys=20(append=20vals=20all-keys))=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(push=20(list=20vals=20body)=20cases))))=0A= -=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((and=20= (macroexp-const-p=20condition)=20condition)=0A-=09=09=20(push=20(list=20= byte-compile--default-val=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(or=20body=20`(,condition)))=0A= -=09=09=20=20=20=20=20=20=20cases)=0A-=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(throw=20'break=20t))=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(t=20(setq=20ok=20nil)=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(throw=20'break=20nil))))))=0A-=20=20=20=20=20=20= =20=20=20(list=20(cons=20prev-test=20prev-var)=20(nreverse=20cases)))))=0A= -=0A-(defun=20byte-compile-cond-jump-table=20(clauses)=0A-=20=20(let*=20= ((table-info=20(byte-compile-cond-jump-table-info=20clauses))=0A-=20=20=20= =20=20=20=20=20=20(test=20(caar=20table-info))=0A-=20=20=20=20=20=20=20=20= =20(var=20(cdar=20table-info))=0A-=20=20=20=20=20=20=20=20=20(cases=20= (cadr=20table-info))=0A-=20=20=20=20=20=20=20=20=20jump-table=20= test-objects=20body=20tag=20donetag=20default-tag=20default-case)=0A-=20=20= =20=20(when=20(and=20cases=20(not=20(=3D=20(length=20cases)=201)))=0A-=20= =20=20=20=20=20;;=20TODO:=20Once=20:linear-search=20is=20implemented=20= for=20`make-hash-table'=0A-=20=20=20=20=20=20;;=20set=20it=20to=20`t'=20= for=20cond=20forms=20with=20a=20small=20number=20of=20cases.=0A-=20=20=20= =20=20=20(let=20((nvalues=20(apply=20#'+=20(mapcar=20(lambda=20(case)=20= (length=20(car=20case)))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= cases))))=0A-=20=20=20=20=20=20=20=20(setq=20jump-table=20= (make-hash-table=0A-=09=09=09=20=20:test=20test=0A-=09=09=09=20=20= :purecopy=20t=0A-=09=09=09=20=20:size=20(if=20(assq=20= byte-compile--default-val=20cases)=0A-=09=09=09=09=20=20=20=20(1-=20= nvalues)=0A-=09=09=09=09=20=20nvalues))))=0A-=20=20=20=20=20=20(setq=20= default-tag=20(byte-compile-make-tag))=0A-=20=20=20=20=20=20(setq=20= donetag=20(byte-compile-make-tag))=0A-=20=20=20=20=20=20;;=20The=20= structure=20of=20byte-switch=20code:=0A-=20=20=20=20=20=20;;=0A-=20=20=20= =20=20=20;;=20varref=20var=0A-=20=20=20=20=20=20;;=20constant=20= #s(hash-table=20purecopy=20t=20data=20(val1=20(TAG1)=20val2=20(TAG2)))=0A= -=20=20=20=20=20=20;;=20switch=0A-=20=20=20=20=20=20;;=20goto=20= DEFAULT-TAG=0A-=20=20=20=20=20=20;;=20TAG1=0A-=20=20=20=20=20=20;;=20= =0A-=20=20=20=20=20=20;;=20goto=20DONETAG=0A-=20=20=20=20=20= =20;;=20TAG2=0A-=20=20=20=20=20=20;;=20=0A-=20=20=20=20=20= =20;;=20goto=20DONETAG=0A-=20=20=20=20=20=20;;=20DEFAULT-TAG=0A-=20=20=20= =20=20=20;;=20=0A-=20=20=20=20=20=20;;=20DONETAG=0A-=0A-=20=20=20=20=20=20= (byte-compile-variable-ref=20var)=0A-=20=20=20=20=20=20= (byte-compile-push-constant=20jump-table)=0A-=20=20=20=20=20=20= (byte-compile-out=20'byte-switch)=0A-=0A-=20=20=20=20=20=20;;=20When=20= the=20opcode=20argument=20is=20`byte-goto',=20`byte-compile-goto'=20sets=0A= -=20=20=20=20=20=20;;=20`byte-compile-depth'=20to=20`nil'.=20However,=20= we=20need=20`byte-compile-depth'=0A-=20=20=20=20=20=20;;=20to=20be=20= non-nil=20for=20generating=20tags=20for=20all=20cases.=20Since=0A-=20=20=20= =20=20=20;;=20`byte-compile-depth'=20will=20increase=20by=20at=20most=20= 1=20after=20compiling=0A-=20=20=20=20=20=20;;=20all=20of=20the=20clause=20= (which=20is=20further=20enforced=20by=20cl-assert=20below)=0A-=20=20=20=20= =20=20;;=20it=20should=20be=20safe=20to=20preserve=20its=20value.=0A-=20=20= =20=20=20=20(let=20((byte-compile-depth=20byte-compile-depth))=0A-=20=20=20= =20=20=20=20=20(byte-compile-goto=20'byte-goto=20default-tag))=0A-=0A-=20= =20=20=20=20=20(let=20((default-match=20(assq=20= byte-compile--default-val=20cases)))=0A-=20=20=20=20=20=20=20=20(when=20= default-match=0A-=09=20=20(setq=20default-case=20(cadr=20default-match)=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20cases=20(butlast=20= cases))))=0A-=0A-=20=20=20=20=20=20(dolist=20(case=20cases)=0A-=20=20=20=20= =20=20=20=20(setq=20tag=20(byte-compile-make-tag)=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20test-objects=20(nth=200=20case)=0A-=20=20=20=20=20=20= =20=20=20=20=20=20=20=20body=20(nth=201=20case))=0A-=20=20=20=20=20=20=20= =20(byte-compile-out-tag=20tag)=0A-=20=20=20=20=20=20=20=20(dolist=20= (value=20test-objects)=0A-=20=20=20=20=20=20=20=20=20=20(puthash=20value=20= tag=20jump-table))=0A-=0A-=20=20=20=20=20=20=20=20(let=20= ((byte-compile-depth=20byte-compile-depth)=0A-=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(init-depth=20byte-compile-depth))=0A-=20=20=20=20=20=20=20= =20=20=20;;=20Since=20`byte-compile-body'=20might=20increase=20= `byte-compile-depth'=0A-=20=20=20=20=20=20=20=20=20=20;;=20by=201,=20not=20= preserving=20its=20value=20will=20cause=20it=20to=20potentially=0A-=20=20= =20=20=20=20=20=20=20=20;;=20increase=20by=20one=20for=20every=20clause=20= body=20compiled,=20causing=0A-=20=20=20=20=20=20=20=20=20=20;;=20= depth/tag=20conflicts=20or=20violating=20asserts=20down=20the=20road.=0A= -=20=20=20=20=20=20=20=20=20=20;;=20To=20make=20sure=20= `byte-compile-body'=20itself=20doesn't=20violate=20this,=0A-=20=20=20=20=20= =20=20=20=20=20;;=20we=20use=20`cl-assert'.=0A-=20=20=20=20=20=20=20=20=20= =20(if=20(null=20body)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (byte-compile-form=20t=20byte-compile--for-effect)=0A-=20=20=20=20=20=20=20= =20=20=20=20=20(byte-compile-body=20body=20byte-compile--for-effect))=0A= -=20=20=20=20=20=20=20=20=20=20(cl-assert=20(or=20(=3D=20= byte-compile-depth=20init-depth)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(=3D=20byte-compile-depth=20(1+=20= init-depth))))=0A-=20=20=20=20=20=20=20=20=20=20(byte-compile-goto=20= 'byte-goto=20donetag)=0A-=20=20=20=20=20=20=20=20=20=20(setcdr=20(cdr=20= donetag)=20nil)))=0A-=0A-=20=20=20=20=20=20(byte-compile-out-tag=20= default-tag)=0A-=20=20=20=20=20=20(if=20default-case=0A-=20=20=20=20=20=20= =20=20=20=20(byte-compile-body-do-effect=20default-case)=0A-=20=20=20=20=20= =20=20=20(byte-compile-constant=20nil))=0A-=20=20=20=20=20=20= (byte-compile-out-tag=20donetag)=0A-=20=20=20=20=20=20(push=20jump-table=20= byte-compile-jump-tables))))=0A+(defun=20= byte-compile--cond-switch-prefix=20(clauses)=0A+=20=20"Find=20a=20switch=20= corresponding=20to=20a=20prefix=20of=20CLAUSES,=20or=20nil=20if=20none.=0A= +Return=20(TAIL=20VAR=20TEST=20CASES),=20where:=0A+=20=20TAIL=20is=20the=20= remaining=20part=20of=20CLAUSES=20after=20the=20switch,=20including=0A+=20= =20any=20default=20clause,=0A+=20=20VAR=20is=20the=20variable=20being=20= switched=20on,=0A+=20=20TEST=20is=20the=20equality=20test=20(`eq',=20= `eql'=20or=20`equal'),=0A+=20=20CASES=20is=20a=20list=20of=20(VALUES=20.=20= BODY)=20where=20VALUES=20is=20a=20list=20of=20values=0A+=20=20=20=20= corresponding=20to=20BODY=20(always=20non-empty)."=0A+=20=20(let=20= ((cases=20nil)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;=20= Reversed=20list=20of=20(VALUES=20BODY).=0A+=20=20=20=20=20=20=20=20(keys=20= nil)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;=20Switch=20= keys=20seen=20so=20far.=0A+=20=20=20=20=20=20=20=20(switch-var=20nil)=0A= +=20=20=20=20=20=20=20=20(switch-test=20'eq))=0A+=20=20=20=20(while=20= (pcase=20(car=20clauses)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= (`((,fn=20,expr1=20,expr2)=20.=20,body)=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(let*=20((vars=20(byte-compile--cond-vars=20expr1=20expr2))=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(var=20= (car=20vars))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(value=20(cdr=20vars)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(and=20var=20(or=20(eq=20var=20switch-var)=20(not=20switch-var))=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(cond=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ((memq=20fn=20'(eq=20eql=20equal))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(setq=20switch-var=20var)=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20= switch-test=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(byte-compile--common-test=20switch-test=20= fn))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(unless=20(member=20value=20keys)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(push=20value=20keys)=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (push=20(cons=20(list=20value)=20(or=20body=20'(t)))=20cases))=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20t)=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((and=20(memq=20= fn=20'(memq=20memql=20member))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(listp=20value)=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ;;=20Require=20a=20non-empty=20body,=20since=20the=20member=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ;;=20function=20value=20depends=20on=20the=20switch=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20= argument.=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20body)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(setq=20switch-var=20var)=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20switch-test=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(byte-compile--common-test=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20switch-test=20= (cdr=20(assq=20fn=20'((memq=20=20=20.=20eq)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (memql=20=20.=20eql)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(member=20.=20= equal))))))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(let=20((vals=20nil))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(dolist=20(elem=20value)=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (unless=20(funcall=20fn=20elem=20keys)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(push=20elem=20= vals)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(when=20vals=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(setq=20keys=20(append=20vals=20= keys))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(push=20(cons=20(nreverse=20vals)=20body)=20cases)))=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= t))))))=0A+=20=20=20=20=20=20(setq=20clauses=20(cdr=20clauses)))=0A+=20=20= =20=20(and=20(>=20(length=20cases)=201)=0A+=20=20=20=20=20=20=20=20=20= (list=20clauses=20switch-var=20switch-test=20(nreverse=20cases)))))=0A+=0A= +(defun=20byte-compile-cond-jump-table=20(switch=20donetag)=0A+=20=20= "Generate=20code=20for=20SWITCH,=20ending=20at=20DONETAG."=0A+=20=20= (let*=20((var=20(car=20switch))=0A+=20=20=20=20=20=20=20=20=20(test=20= (nth=201=20switch))=0A+=20=20=20=20=20=20=20=20=20(cases=20(nth=202=20= switch))=0A+=20=20=20=20=20=20=20=20=20jump-table=20test-objects=20body=20= tag=20default-tag)=0A+=20=20=20=20;;=20TODO:=20Once=20:linear-search=20= is=20implemented=20for=20`make-hash-table'=0A+=20=20=20=20;;=20set=20it=20= to=20`t'=20for=20cond=20forms=20with=20a=20small=20number=20of=20cases.=0A= +=20=20=20=20(let=20((nvalues=20(apply=20#'+=20(mapcar=20(lambda=20= (case)=20(length=20(car=20case)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20cases))))=0A+=20=20=20=20=20=20(setq=20jump-table=20(make-hash-table=0A= +=09=09=09:test=20test=0A+=09=09=09:purecopy=20t=0A+=09=09=09:size=20= nvalues)))=0A+=20=20=20=20(setq=20default-tag=20(byte-compile-make-tag))=0A= +=20=20=20=20;;=20The=20structure=20of=20byte-switch=20code:=0A+=20=20=20= =20;;=0A+=20=20=20=20;;=20varref=20var=0A+=20=20=20=20;;=20constant=20= #s(hash-table=20purecopy=20t=20data=20(val1=20(TAG1)=20val2=20(TAG2)))=0A= +=20=20=20=20;;=20switch=0A+=20=20=20=20;;=20goto=20DEFAULT-TAG=0A+=20=20= =20=20;;=20TAG1=0A+=20=20=20=20;;=20=0A+=20=20=20=20;;=20= goto=20DONETAG=0A+=20=20=20=20;;=20TAG2=0A+=20=20=20=20;;=20=0A+=20=20=20=20;;=20goto=20DONETAG=0A+=20=20=20=20;;=20DEFAULT-TAG=0A= +=20=20=20=20;;=20=0A+=20= =20=20=20;;=20DONETAG=0A+=0A+=20=20=20=20(byte-compile-variable-ref=20= var)=0A+=20=20=20=20(byte-compile-push-constant=20jump-table)=0A+=20=20=20= =20(byte-compile-out=20'byte-switch)=0A+=0A+=20=20=20=20;;=20When=20the=20= opcode=20argument=20is=20`byte-goto',=20`byte-compile-goto'=20sets=0A+=20= =20=20=20;;=20`byte-compile-depth'=20to=20`nil'.=20However,=20we=20need=20= `byte-compile-depth'=0A+=20=20=20=20;;=20to=20be=20non-nil=20for=20= generating=20tags=20for=20all=20cases.=20Since=0A+=20=20=20=20;;=20= `byte-compile-depth'=20will=20increase=20by=20at=20most=201=20after=20= compiling=0A+=20=20=20=20;;=20all=20of=20the=20clause=20(which=20is=20= further=20enforced=20by=20cl-assert=20below)=0A+=20=20=20=20;;=20it=20= should=20be=20safe=20to=20preserve=20its=20value.=0A+=20=20=20=20(let=20= ((byte-compile-depth=20byte-compile-depth))=0A+=20=20=20=20=20=20= (byte-compile-goto=20'byte-goto=20default-tag))=0A+=0A+=20=20=20=20= (dolist=20(case=20cases)=0A+=20=20=20=20=20=20(setq=20tag=20= (byte-compile-make-tag)=0A+=20=20=20=20=20=20=20=20=20=20=20=20= test-objects=20(car=20case)=0A+=20=20=20=20=20=20=20=20=20=20=20=20body=20= (cdr=20case))=0A+=20=20=20=20=20=20(byte-compile-out-tag=20tag)=0A+=20=20= =20=20=20=20(dolist=20(value=20test-objects)=0A+=20=20=20=20=20=20=20=20= (puthash=20value=20tag=20jump-table))=0A+=0A+=20=20=20=20=20=20(let=20= ((byte-compile-depth=20byte-compile-depth)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20(init-depth=20byte-compile-depth))=0A+=20=20=20=20=20=20=20=20= ;;=20Since=20`byte-compile-body'=20might=20increase=20= `byte-compile-depth'=0A+=20=20=20=20=20=20=20=20;;=20by=201,=20not=20= preserving=20its=20value=20will=20cause=20it=20to=20potentially=0A+=20=20= =20=20=20=20=20=20;;=20increase=20by=20one=20for=20every=20clause=20body=20= compiled,=20causing=0A+=20=20=20=20=20=20=20=20;;=20depth/tag=20= conflicts=20or=20violating=20asserts=20down=20the=20road.=0A+=20=20=20=20= =20=20=20=20;;=20To=20make=20sure=20`byte-compile-body'=20itself=20= doesn't=20violate=20this,=0A+=20=20=20=20=20=20=20=20;;=20we=20use=20= `cl-assert'.=0A+=20=20=20=20=20=20=20=20(byte-compile-body=20body=20= byte-compile--for-effect)=0A+=20=20=20=20=20=20=20=20(cl-assert=20(or=20= (=3D=20byte-compile-depth=20init-depth)=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(=3D=20byte-compile-depth=20(1+=20= init-depth))))=0A+=20=20=20=20=20=20=20=20(byte-compile-goto=20= 'byte-goto=20donetag)=0A+=20=20=20=20=20=20=20=20(setcdr=20(cdr=20= donetag)=20nil)))=0A+=0A+=20=20=20=20(byte-compile-out-tag=20= default-tag)=0A+=20=20=20=20(push=20jump-table=20= byte-compile-jump-tables)))=0A=20=0A=20(defun=20byte-compile-cond=20= (clauses)=0A-=20=20(or=20(and=20byte-compile-cond-use-jump-table=0A-=20=20= =20=20=20=20=20=20=20=20=20(byte-compile-cond-jump-table=20clauses))=0A-=20= =20=20=20(let=20((donetag=20(byte-compile-make-tag))=0A-=20=20=20=20=20=20= =20=20=20=20nexttag=20clause)=0A-=20=20=20=20=20=20(while=20(setq=20= clauses=20(cdr=20clauses))=0A-=20=20=20=20=20=20=20=20(setq=20clause=20= (car=20clauses))=0A-=20=20=20=20=20=20=20=20(cond=20((or=20(eq=20(car=20= clause)=20t)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (and=20(eq=20(car-safe=20(car=20clause))=20'quote)=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(car-safe=20(cdr-safe=20= (car=20clause)))))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20= Unconditional=20clause=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (setq=20clause=20(cons=20t=20clause)=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20clauses=20nil))=0A-=20=20=20=20=20=20=20=20= =20=20=20=20=20=20((cdr=20clauses)=0A-=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(byte-compile-form=20(car=20clause))=0A-=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(if=20(null=20(cdr=20clause))=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20;;=20First=20clause=20is=20a=20= singleton.=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (byte-compile-goto-if=20t=20byte-compile--for-effect=20donetag)=0A-=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20nexttag=20= (byte-compile-make-tag))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(byte-compile-goto=20'byte-goto-if-nil=20nexttag)=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(byte-compile-maybe-guarded=20(car=20= clause)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (byte-compile-body=20(cdr=20clause)=20byte-compile--for-effect))=0A-=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(byte-compile-goto=20= 'byte-goto=20donetag)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(byte-compile-out-tag=20nexttag)))))=0A-=20=20=20=20=20=20;;=20Last=20= clause=0A-=20=20=20=20=20=20(let=20((guard=20(car=20clause)))=0A-=20=20=20= =20=20=20=20=20(and=20(cdr=20clause)=20(not=20(eq=20guard=20t))=0A-=20=20= =20=20=20=20=20=20=20=20=20=20=20(progn=20(byte-compile-form=20guard)=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (byte-compile-goto-if=20nil=20byte-compile--for-effect=20donetag)=0A-=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20clause=20= (cdr=20clause))))=0A-=20=20=20=20=20=20=20=20(byte-compile-maybe-guarded=20= guard=0A-=20=20=20=20=20=20=20=20=20=20(byte-compile-body-do-effect=20= clause)))=0A-=20=20=20=20=20=20(byte-compile-out-tag=20donetag))))=0A+=20= =20(let=20((donetag=20(byte-compile-make-tag))=0A+=20=20=20=20=20=20=20=20= nexttag=20clause)=0A+=20=20=20=20(setq=20clauses=20(cdr=20clauses))=0A+=20= =20=20=20(while=20clauses=0A+=20=20=20=20=20=20(let=20((switch-prefix=20= (and=20byte-compile-cond-use-jump-table=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (byte-compile--cond-switch-prefix=20clauses))))=0A+=20=20=20=20=20=20=20=20= (if=20switch-prefix=0A+=20=20=20=20=20=20=20=20=20=20=20=20(progn=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(byte-compile-cond-jump-table=20(cdr=20= switch-prefix)=20donetag)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (setq=20clauses=20(car=20switch-prefix)))=0A+=20=20=20=20=20=20=20=20=20=20= (setq=20clause=20(car=20clauses))=0A+=20=20=20=20=20=20=20=20=20=20(cond=20= ((or=20(eq=20(car=20clause)=20t)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(and=20(eq=20(car-safe=20(car=20clause))=20= 'quote)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(car-safe=20(cdr-safe=20(car=20clause)))))=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20;;=20Unconditional=20clause=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20clause=20(cons=20= t=20clause)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20clauses=20nil))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20((cdr=20clauses)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (byte-compile-form=20(car=20clause))=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(if=20(null=20(cdr=20clause))=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20;;=20First=20clause=20is=20a=20= singleton.=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(byte-compile-goto-if=20t=20byte-compile--for-effect=20donetag)=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20nexttag=20= (byte-compile-make-tag))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(byte-compile-goto=20'byte-goto-if-nil=20nexttag)=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (byte-compile-maybe-guarded=20(car=20clause)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(byte-compile-body=20(cdr=20clause)=20= byte-compile--for-effect))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(byte-compile-goto=20'byte-goto=20donetag)=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(byte-compile-out-tag=20= nexttag))))=0A+=20=20=20=20=20=20=20=20=20=20(setq=20clauses=20(cdr=20= clauses)))))=0A+=20=20=20=20;;=20Last=20clause=0A+=20=20=20=20(let=20= ((guard=20(car=20clause)))=0A+=20=20=20=20=20=20(and=20(cdr=20clause)=20= (not=20(eq=20guard=20t))=0A+=20=20=20=20=20=20=20=20=20=20=20(progn=20= (byte-compile-form=20guard)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(byte-compile-goto-if=20nil=20byte-compile--for-effect=20= donetag)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20= clause=20(cdr=20clause))))=0A+=20=20=20=20=20=20= (byte-compile-maybe-guarded=20guard=0A+=20=20=20=20=20=20=20=20= (byte-compile-body-do-effect=20clause)))=0A+=20=20=20=20= (byte-compile-out-tag=20donetag)))=0A=20=0A=20(defun=20byte-compile-and=20= (form)=0A=20=20=20(let=20((failtag=20(byte-compile-make-tag))=0Adiff=20= --git=20a/test/lisp/emacs-lisp/bytecomp-tests.el=20= b/test/lisp/emacs-lisp/bytecomp-tests.el=0Aindex=20= 87f2c13bf7..b2a47af63b=20100644=0A---=20= a/test/lisp/emacs-lisp/bytecomp-tests.el=0A+++=20= b/test/lisp/emacs-lisp/bytecomp-tests.el=0A@@=20-334,7=20+334,20=20@@=20= byte-opt-testsuite-arith-data=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((memql=20x=20'(9=20= 0.5=201.5=20q))=2066)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(t=2099)))=0A=20=20=20=20=20=20= =20=20=20=20=20=20=20'(a=20b=20c=20d=20(d)=20(a=20.=20b)=20"X"=200.5=20= 1.5=203.14=209=209.0))=0A-=20=20=20=20)=0A+=20=20=20=20;;=20Multi-switch=20= cond=20form=0A+=20=20=20=20(mapcar=20(lambda=20(p)=20(let=20((x=20(car=20= p))=20(y=20(cadr=20p)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(cond=20((consp=20x)=2011)=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20((eq=20x=20'a)=2022)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((memql=20x=20'(b=207=20= a=20-3))=2033)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20((equal=20y=20"a")=2044)=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20((memq=20y=20'(c=20d=20e))=2055)=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ((booleanp=20x)=2066)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20((eq=20x=20'q)=2077)=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20((memq=20x=20'(r=20s))=2088)=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ((eq=20x=20't)=2099)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(t=20999))))=0A+=20=20=20=20= =20=20=20=20=20=20=20=20'((a=20c)=20(b=20c)=20(7=20c)=20(-3=20c)=20(nil=20= nil)=20(t=20c)=20(q=20c)=20(r=20c)=20(s=20c)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(t=20c)=20(x=20"a")=20(x=20"c")=20(x=20c)=20(x=20d)=20(x=20= e))))=0A=20=20=20"List=20of=20expression=20for=20test.=0A=20Each=20= element=20will=20be=20executed=20by=20interpreter=20and=20with=0A=20= bytecompiled=20code,=20and=20their=20results=20compared.")=0A--=20=0A= 2.20.1=20(Apple=20Git-117)=0A=0A= --Apple-Mail=_6425368A-6F6F-40E3-9751-3E52F91F6248-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 08 11:39:21 2019 Received: (at 36139) by debbugs.gnu.org; 8 Jun 2019 15:39:21 +0000 Received: from localhost ([127.0.0.1]:53533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hZdRB-0003yC-1u for submit@debbugs.gnu.org; Sat, 08 Jun 2019 11:39:21 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:34588) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hZdR9-0003xy-88 for 36139@debbugs.gnu.org; Sat, 08 Jun 2019 11:39:19 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x58Fcxsu076156; Sat, 8 Jun 2019 15:38:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=l+qLscS6lPhBjNX2mgfSxSiUD0oLssXqPiQ/bQ1VHjk=; b=E59ZiXZvWPFg9pHkwMdSaImfY73a8vzrKpxgMkTc3A++tgL1MAUErEoiT5wbgthnUCMY lkkoOaVdnA8MQOJC/7bRSV6Af5Wzxk3v35ym+2Cl/BAazOhS2XWgj1rR6inNroyMYE9l jknGlcbIKa14EanAn1tTlmCoT5m4JxmY86QkvNVCqqGkfo3Sy9QFYu0R3DZF+pvtUdXq 9cJXaROkQpiIX3DbbkIbPgKiSLL1bh0sWu6F741uxX++MzPicBvuIWEhKaiIxpP8YWu7 f2+ZGZJkjjJhBvUhMzEvDK05Jb0ODlyDTqzZRK0fP2m5EFNonadnUxOZ3KVOem5eRKab kw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 2t02he9ggv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 08 Jun 2019 15:38:59 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x58Fc5sF129544; Sat, 8 Jun 2019 15:38:58 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2t0aa921n3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 08 Jun 2019 15:38:58 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x58Fctkq027191; Sat, 8 Jun 2019 15:38:57 GMT MIME-Version: 1.0 Message-ID: <395efab3-80f6-4ff0-b754-9f58dd4af695@default> Date: Sat, 8 Jun 2019 08:38:54 -0700 (PDT) From: Drew Adams To: =?iso-8859-1?B?TWF0dGlhcyBFbmdkZWflcmQ=?= , 36139@debbugs.gnu.org Subject: RE: bug#36139: [PATCH] Make better use of the switch op in cond forms References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> In-Reply-To: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4849.0 (x86)] Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9282 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=852 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906080117 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9282 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=899 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906080117 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 36139 Cc: Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) How does this kind of thing work with an enclosing `cl-flet' or similar tha= t redefines `memq' or whatever? Or in a file that redefines `memq' or what= ever using `defun' or similar? (But I guess the same problem exists in the current code, wrt `eq' etc.?) From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 09 04:38:34 2019 Received: (at 36139) by debbugs.gnu.org; 9 Jun 2019 08:38:34 +0000 Received: from localhost ([127.0.0.1]:54226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hZtLW-0006JE-Dd for submit@debbugs.gnu.org; Sun, 09 Jun 2019 04:38:34 -0400 Received: from mail74c50.megamailservers.eu ([91.136.10.84]:56432 helo=mail92c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hZtLU-0006J3-At for 36139@debbugs.gnu.org; Sun, 09 Jun 2019 04:38:33 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1560069510; bh=UL7nQ23a3ur5G4nDH38RmnwSaQW+vvMcKYE/Rx6YIKM=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=EcPaxmdp4Aa979XqnsLwh0DZitbIasrQcstgL7mrkmLKqE5+T/+dEeG7EQltWYuFD tqgNaAPRB7UVU65Gd//8rNpKKqSEwNKGk1rsNdu1DH7D49+VhwbnzbMExx7kOECgSI 7mEvpz073sIbljSvxlLPzp+eOnV3O09QZtsrItbE= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] ([188.150.171.71]) (authenticated bits=0) by mail92c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x598cPJB015199; Sun, 9 Jun 2019 08:38:27 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= X-Priority: 3 In-Reply-To: <395efab3-80f6-4ff0-b754-9f58dd4af695@default> Date: Sun, 9 Jun 2019 10:38:25 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> <395efab3-80f6-4ff0-b754-9f58dd4af695@default> To: Drew Adams X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0204.5CFCC586.0008, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=LZQSFAXi c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=yPCof4ZbAAAA:8 a=gGedW7438y1x64hWVBkA:9 a=CjuIK1q_8ugA:10 X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) 8 juni 2019 kl. 17.38 skrev Drew Adams : >=20 > How does this kind of thing work with an enclosing `cl-flet' or = similar that redefines `memq' or whatever? Or in a file that redefines = `memq' or whatever using `defun' or similar? `cl-flet' works by macro-expansion, not by lexical rebinding of the = function value, so it should be reasonably safe. monotonic= From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 10 11:39:12 2019 Received: (at 36139) by debbugs.gnu.org; 10 Jun 2019 15:39:12 +0000 Received: from localhost ([127.0.0.1]:57382 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1haMO8-0005Ps-0s for submit@debbugs.gnu.org; Mon, 10 Jun 2019 11:39:12 -0400 Received: from mail-io1-f41.google.com ([209.85.166.41]:37290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1haMO0-0005P9-J1 for 36139@debbugs.gnu.org; Mon, 10 Jun 2019 11:39:09 -0400 Received: by mail-io1-f41.google.com with SMTP id e5so7232186iok.4 for <36139@debbugs.gnu.org>; Mon, 10 Jun 2019 08:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=yOFdehyXtuAOyrTf36B3hLsIUj/CZ/ViWoDHGyhDkcQ=; b=SUw+4g/up7PIyf4PV2sTG9bU9csvG/E+1FZITMClHNRLxEoWNDqfRvePmud3xGysdI Gxxzo9qRX9633daQwxlBpJFaptC409lXLUZvht+T7tOy584LJSC+cM4WQWB4YdlSapLk E403Gdp8Rhc7JE1pVzVz64rXvvJjJsZRmVoQ5DkeSEb90bfeKZr7FGsiqnEuSpYsl0Jx bHcRXFgcMM8bQpdOPI6KSXK8BSyGwvix2Tpfe9i+LxoamSbaCfIEPC4FRVe0PgQGsO9t aub+NQAZeX2F7Rd2t0sHzG0Zjkt7YgqBk3u4lqUbE0OBFjTDWrA7X4P90RX3Yyc/emmi kjhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=yOFdehyXtuAOyrTf36B3hLsIUj/CZ/ViWoDHGyhDkcQ=; b=MpCgFowLflU4lElGKwoKVhvPvPkVxHY/aF9F27tqS0+iacl9WkE4s5mZLMZMj8cZiG QJh3VsnQ0Ib0tZ4u3bha0dmz5HsmVdQ2DUZwtBs5O74N2txM1xmdIJzes/Hh7KgXuLhE RSg/ZnaNW1nYgqzcWIPWRVWtjsZDP3OaZ41R585z6SCmQeFdLO/ukCj222KidSi8D2jf q4gFTgL01EXGwvaa5JjyT1CLzeaNQZuCXtArWkwcFqBQhh+Y0Ec/tSPoypMfVR5Ohcpd Ytbu6VDwbhWWNY7v82yF/3AJ9u0GWe2lCLbKINkx0/YddXThCgJwfdX2174ehvdFJD0Q O84g== X-Gm-Message-State: APjAAAU3IdjYvd6VereZa6z6DjW6S3wc4jMkxL5Sgw/IEIIBbXisXxjg bzXfBn6u+ydYaYNmULdcpvk= X-Google-Smtp-Source: APXvYqyBtEEs8BjvbW4dv8qLHKk2hZBJ9NRHBjwq59/HCgJcClcUVxU6YCl6f285VO+2QuatquY2zg== X-Received: by 2002:a05:6602:2104:: with SMTP id x4mr8747285iox.260.1560181138966; Mon, 10 Jun 2019 08:38:58 -0700 (PDT) Received: from vhost2 (CPE001143542e1f-CMf81d0f809fa0.cpe.net.cable.rogers.com. [99.230.51.196]) by smtp.gmail.com with ESMTPSA id w23sm3881812ioa.51.2019.06.10.08.38.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jun 2019 08:38:58 -0700 (PDT) From: npostavs@gmail.com To: Drew Adams Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> <395efab3-80f6-4ff0-b754-9f58dd4af695@default> Date: Mon, 10 Jun 2019 11:38:57 -0400 In-Reply-To: <395efab3-80f6-4ff0-b754-9f58dd4af695@default> (Drew Adams's message of "Sat, 8 Jun 2019 08:38:54 -0700 (PDT)") Message-ID: <85d0jlbgby.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.92 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36139 Cc: Mattias =?iso-8859-1?Q?Engdeg=E5rd?= , 36139@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Drew Adams writes: > Or in a file that redefines `memq' or whatever using `defun' or similar? > > (But I guess the same problem exists in the current code, wrt `eq' etc.?) Redefining eq, equal, memq, or member with defun or advice is already unreliable because they are translated to byte codes. eql and memql are not, so this patchset (specifically, the last 2 patches, I think) would make the situation a bit worse for those functions, in that it would prevent defun/advice override for eql and memql from applying in cond forms. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 11 07:12:41 2019 Received: (at 36139) by debbugs.gnu.org; 11 Jun 2019 11:12:41 +0000 Received: from localhost ([127.0.0.1]:58073 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1haehk-0005Gc-No for submit@debbugs.gnu.org; Tue, 11 Jun 2019 07:12:40 -0400 Received: from mail1424c50.megamailservers.eu ([91.136.14.24]:58812 helo=mail102c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1haehh-0005GL-Mf for 36139@debbugs.gnu.org; Tue, 11 Jun 2019 07:12:39 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1560251550; bh=6PZSKF/Bj6wW/YzDVWUMfX8iGRBXh9ODaJgPAVjWyOQ=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=cEVtWAGSTjDVfZAtPyKuCGeMYEaNlEytXqTkWgQ6r9jVWGGBsY86MbGOq/jAPLbCf fkKAK87WlH4fDyJ6q9ub1fRzm2CsEPjRlc7BRmLGKKLnUO3MF7MhuKa2NB2mhBewTX wT4hZ0hXHH1rh4fp2frIlZlWcn4EUPwmWXmapmR8= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] ([188.150.171.71]) (authenticated bits=0) by mail102c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5BBCQO1012747; Tue, 11 Jun 2019 11:12:28 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: <85d0jlbgby.fsf@gmail.com> Date: Tue, 11 Jun 2019 13:12:26 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <0D7CFFA0-FC7E-4D4E-A24C-4893776229B0@acm.org> References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> <395efab3-80f6-4ff0-b754-9f58dd4af695@default> <85d0jlbgby.fsf@gmail.com> To: Noam Postavsky X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B020F.5CFF8C9E.008A, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=F7x5iJpN c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=pGLkceISAAAA:8 a=B8kNJ6x5S7mYufQQh20A:9 a=CjuIK1q_8ugA:10 X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org, Stefan Monnier , Drew Adams X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 10 juni 2019 kl. 17.38 skrev npostavs@gmail.com: >=20 > Redefining eq, equal, memq, or member with defun or advice is already > unreliable because they are translated to byte codes. eql and memql = are > not, so this patchset (specifically, the last 2 patches, I think) = would > make the situation a bit worse for those functions, in that it would > prevent defun/advice override for eql and memql from applying in cond > forms. `eql' is already recognised for switch generation in cond forms today. = More generally, is redefinition of such fundamental built-ins really a = serious concern? The compiler assumes standard semantics for plenty of = functions, byte-codes or not. This is also mentioned in the manual. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 11 07:25:14 2019 Received: (at 36139) by debbugs.gnu.org; 11 Jun 2019 11:25:14 +0000 Received: from localhost ([127.0.0.1]:58079 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1haett-0005a6-Uw for submit@debbugs.gnu.org; Tue, 11 Jun 2019 07:25:14 -0400 Received: from mail-it1-f172.google.com ([209.85.166.172]:38603) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1haets-0005Zr-GQ for 36139@debbugs.gnu.org; Tue, 11 Jun 2019 07:25:12 -0400 Received: by mail-it1-f172.google.com with SMTP id e25so4107212itk.3 for <36139@debbugs.gnu.org>; Tue, 11 Jun 2019 04:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=NuwEaZe4dqrDqa5YSVJhvsYN6JY1YtNrAwzwnpDVfPo=; b=hxo38nv8jf7x4cdIBwQxQClMAEib321dk0F7daatQlfFrYWUAyZiYdGhv4yLwjVQx0 30MLSfVHdFW/617gKy8SDWn0jTfVVeN3473D6x8IF5EhaERCpkT+aZ5/nyLr8NaEHV61 58xoy+bpSTJMZI3WATLwabsifxHx7XSpJ9RukfpGLnBRg7jRliia321WewQrpKhVyTXs rrhBuRlWG3zmFJQZ6TIiYb7Hay68zzarBGNTIiOt6HeCNVHRrTUYuAubz+IOHaNUKxmq yKWKFZCWb3WkiiXCFvj+mLslzNvUD5klyf+w0KCZ2/u+MGtda7GwL/HUc5UB0u3IajMR zE/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=NuwEaZe4dqrDqa5YSVJhvsYN6JY1YtNrAwzwnpDVfPo=; b=H5IRlIfcy86wNW6Y/vT19zSuxwZDKyjyIw+lgcT63J5Wpg+tBdfwOXDS24H2QuEaPj lLbM2ah/FVMt/BJWkJaw0AagILbzY9o1gnB/jbX7VuVuJ4mkcQ6z/lFzC5wJ+SJYOCF3 AhbrEzzaZeZVKfeF9BGosfI8gEeyvOttP+5mD0HCUbiIq4DsYCvuAkkcRjRjeQK0OV0H zn6dRucZV1VdOTWpbYoB4Aq0rYUi+hsq7lE0a76e/Gcz78KKEBW6RFM10gYyBGZoRTNx Sr1hWbFN/uo+RAq8mT+3NiUIeChv200RZ3j5Jo9Zut0bMvCL3x+G5WCGCBKIWQaK74fd XZ8g== X-Gm-Message-State: APjAAAXDPeFcqzkfa9it2qvzG3aU0ZSSInF01xsnlNiLno7LrZotbFVY FD8O/NpLUIJCzoAHa88eFmE= X-Google-Smtp-Source: APXvYqzeZGwFsMCBwubqju56sCqxQzIj6WnxnTyvnXBFYZhcpfbbg29eRWne3i4OOwxK/0o5Law9Lg== X-Received: by 2002:a05:660c:482:: with SMTP id a2mr15847980itk.91.1560252306608; Tue, 11 Jun 2019 04:25:06 -0700 (PDT) Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id y194sm1102446itb.34.2019.06.11.04.25.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Jun 2019 04:25:05 -0700 (PDT) From: Noam Postavsky To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> <395efab3-80f6-4ff0-b754-9f58dd4af695@default> <85d0jlbgby.fsf@gmail.com> <0D7CFFA0-FC7E-4D4E-A24C-4893776229B0@acm.org> Date: Tue, 11 Jun 2019 07:25:05 -0400 In-Reply-To: <0D7CFFA0-FC7E-4D4E-A24C-4893776229B0@acm.org> ("Mattias \=\?utf-8\?Q\?Engdeg\=C3\=A5rd\=22's\?\= message of "Tue, 11 Jun 2019 13:12:26 +0200") Message-ID: <87wohsz7n2.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org, Stefan Monnier , Drew Adams X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: > 10 juni 2019 kl. 17.38 skrev npostavs@gmail.com: >>=20 >> Redefining eq, equal, memq, or member with defun or advice is already >> unreliable because they are translated to byte codes. eql and memql are >> not, so this patchset (specifically, the last 2 patches, I think) would >> make the situation a bit worse for those functions, in that it would >> prevent defun/advice override for eql and memql from applying in cond >> forms. > > `eql' is already recognised for switch generation in cond forms > today. Oh, I wasn't aware of that. Somehow I had the impression it was only for `eq'. > More generally, is redefinition of such fundamental built-ins > really a serious concern? Not in my opinion, I just wanted to mention it for completeness. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 18 08:46:57 2019 Received: (at 36139) by debbugs.gnu.org; 18 Jun 2019 12:46:57 +0000 Received: from localhost ([127.0.0.1]:43910 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdDVp-0004vq-Dy for submit@debbugs.gnu.org; Tue, 18 Jun 2019 08:46:57 -0400 Received: from mail1430c50.megamailservers.eu ([91.136.14.30]:52564 helo=mail118c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdDVl-0004vK-Uo for 36139@debbugs.gnu.org; Tue, 18 Jun 2019 08:46:55 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1560862007; bh=tMVC7xakDfB130ulGJyIDgHL3klihAzh6HboJOntDjI=; h=From:Subject:Date:References:To:In-Reply-To:From; b=QQ0qjNi0/ABfvYWjxSfENksoZGvL7/ntXnbAXbBAW/s/h3CEK8oV6/Tb+pnAM9j8G HdV55DcZ9YPaXCsHi6N0qVymKiWdMepBpYSjuwfjOtVXaHylLJZpPz07iSDG9CdjRF 9ltllnx1XglVVvjnzDrK11aTXzo9b3F8wx1watdQ= Feedback-ID: mattiase@acm.or Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail118c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5ICkiwb014725; Tue, 18 Jun 2019 12:46:46 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms Date: Tue, 18 Jun 2019 14:46:43 +0200 References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> <395efab3-80f6-4ff0-b754-9f58dd4af695@default> <85d0jlbgby.fsf@gmail.com> <0D7CFFA0-FC7E-4D4E-A24C-4893776229B0@acm.org> <87wohsz7n2.fsf@gmail.com> To: 36139@debbugs.gnu.org, Stefan Monnier , Noam Postavsky , Drew Adams In-Reply-To: <87wohsz7n2.fsf@gmail.com> Message-Id: <660B7461-C487-4BD6-B1E3-953D9367B868@acm.org> X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0206.5D08DD37.0036, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=PfPReBpd c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=CQs3cQXTMkAgUmz6C2AA:9 a=CjuIK1q_8ugA:10 X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 36139 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Anything I can do to make the changes easier to review? All tests pass, = bootstrap works, and so on; I'm using them daily. The patches could be reviewed and committed piecemeal. Patch 3 (pcase) = may be a good start since it's a small independent improvement. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 18 14:49:01 2019 Received: (at 36139) by debbugs.gnu.org; 18 Jun 2019 18:49:01 +0000 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 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 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) 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== 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) From: Stefan Monnier To: Mattias =?windows-1252?Q?Engdeg=E5rd?= Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms Message-ID: References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> Date: Tue, 18 Jun 2019 14:48:44 -0400 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") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > * 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 From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 18 14:56:57 2019 Received: (at 36139) by debbugs.gnu.org; 18 Jun 2019 18:56:57 +0000 Received: from localhost ([127.0.0.1]:45596 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdJHt-0005W7-Fk for submit@debbugs.gnu.org; Tue, 18 Jun 2019 14:56:57 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39417) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdJHp-0005Vn-83 for 36139@debbugs.gnu.org; Tue, 18 Jun 2019 14:56:54 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 99EF681171; Tue, 18 Jun 2019 14:56:47 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 141B280E0B; Tue, 18 Jun 2019 14:56:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1560884206; bh=QYULeppMHyo/QkQT0nsx3f4VBNWJWxeBU6a9YqhTLCU=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=kSF1VynXJgxB9FbeBDKwzoKpklIMqgSwzmfPSA2QpQtzWTycyilqHPKCXyQAFAIMg tIUZXwC7eD8+IrVvOx6aOPvryuXuTkKHPSx0QRB7PhSNJ7FTiZ8SmCFMyKPAjqKBsk u8p/A+/IqEE0PNeTl+kT2wbY2dXZQmd8JJAdzp3Vaj/BuXDJz139LwZ9ieLlx+76NA z+St97+yheAdFDtyZP6us5bh+WHNzmXFTDdxLe9BDK4cZXnfQlufG2fkolG9n4ighE iPBFcG3tUWfkzm4ZTUZ4RLszrcIk20I8oGi4COxiv95E5Oz91c+1I1qGyW2/sf/989 dAt0v+DYNyRkg== Received: from alfajor (unknown [157.52.10.58]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BFC8A120AD4; Tue, 18 Jun 2019 14:56:45 -0400 (EDT) From: Stefan Monnier To: Mattias =?windows-1252?Q?Engdeg=E5rd?= Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms Message-ID: References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> Date: Tue, 18 Jun 2019 14:56:44 -0400 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") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.008 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > Allow switch generation with a mixture of eq, eql, equal, memq, memql and member. AFAIK all of those give the same result (in practice) as using equal/member: I'm having a hard time imagining an eq/eql/memq/memql test against a constant which behaves differently from equal/member except for those that can simply always return nil (e.g. (eq x "toto") can always return nil since there's no way the caller of this code can make sure x is really the same string object as the "toto" generated by the compiler). So I think we should "standardize" on equal/member and mostly disregard the eq/eql/equal difference (except maybe for emitting a warning when comparing against something where `equal` doesn't give the same result). Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 18 15:03:14 2019 Received: (at 36139) by debbugs.gnu.org; 18 Jun 2019 19:03:14 +0000 Received: from localhost ([127.0.0.1]:45608 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdJNy-0005iw-H1 for submit@debbugs.gnu.org; Tue, 18 Jun 2019 15:03:14 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:46764) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdJNw-0005ij-F5 for 36139@debbugs.gnu.org; Tue, 18 Jun 2019 15:03:12 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 930D881171; Tue, 18 Jun 2019 15:03:05 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4B43980E0B; Tue, 18 Jun 2019 15:03:04 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1560884584; bh=6a9pQncjOrlLrf37c4fj1Ic64Md5BXAMUKz4jjvynQ0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=gsNTwUWDSvRn73zi2VHT9LkYvDI4fCZoKSgDuLuYAL7Cgw2uygzqGBPrVOZ8zpEkx YUxsGR9PjiW6g5lqHMlbP0OCrLml9vCpIOqdW1keW6hULIwEYfNN1qEL+pueTd64Vu SUacUfrHrmwqYbkWtXTKvgOefGp9OqQNr0fv8nJaSfD4P3/zSUDVvZJdZBbS+DW2Vq SFiLZ/ZTdtlH40Af1r1gkS38DTZHM3hLMM19sE9tVF+KQMvqo9DE70KFtRuZiEe4vG An5tcWSbxtqFOCUPBxIxdqTiQ8lZLA+qEIyMCOmOuYS1r/wtzn+W636OIPX6sn+l6V hhO25dPZBaBwA== Received: from alfajor (unknown [157.52.10.58]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 7BDC51203AB; Tue, 18 Jun 2019 15:03:03 -0400 (EDT) From: Stefan Monnier To: Mattias =?windows-1252?Q?Engdeg=E5rd?= Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms Message-ID: References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> Date: Tue, 18 Jun 2019 15:03:01 -0400 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") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.008 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > * lisp/emacs-lisp/pcase.el (pcase--u1): > Use the most specific of `memq', `memql' and `member' in or-patterns > with constant cases. This improves performance and may help the byte-code > compiler generate a switch. > * test/lisp/emacs-lisp/pcase-tests.el (pcase-tests-member): > Add mixed-type or-pattern test cases. > --- > lisp/emacs-lisp/pcase.el | 15 ++++++++------- > test/lisp/emacs-lisp/pcase-tests.el | 6 ++++-- > 2 files changed, 12 insertions(+), 9 deletions(-) > > diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el > index a644453a94..ae2cf8eb02 100644 > --- a/lisp/emacs-lisp/pcase.el > +++ b/lisp/emacs-lisp/pcase.el > @@ -785,25 +785,26 @@ pcase--u1 > ((eq 'or (caar matches)) > (let* ((alts (cdar matches)) > (var (if (eq (caar alts) 'match) (cadr (car alts)))) > - (simples '()) (others '()) (memql-ok t)) > + (simples '()) (others '()) (mem-fun 'memq)) > (when var > (dolist (alt alts) > (if (and (eq (car alt) 'match) (eq var (cadr alt)) > (let ((upat (cddr alt))) > (eq (car-safe upat) 'quote))) > (let ((val (cadr (cddr alt)))) > - (unless (or (integerp val) (symbolp val)) > - (setq memql-ok nil)) > - (push (cadr (cddr alt)) simples)) > + (cond ((integerp val) > + (when (eq mem-fun 'memq) > + (setq mem-fun 'memql))) > + ((not (symbolp val)) > + (setq mem-fun 'member))) > + (push val simples)) > (push alt others)))) > (cond > ((null alts) (error "Please avoid it") (pcase--u rest)) > ;; Yes, we can use `memql' (or `member')! > ((> (length simples) 1) > (pcase--u1 (cons `(match ,var > - . (pred (pcase--flip > - ,(if memql-ok #'memql #'member) > - ',simples))) > + . (pred (pcase--flip ,mem-fun ',simples))) > (cdr matches)) > code vars > (if (null others) rest LGTM. The other direction is to just always use `member` and speed up the implementation of `member` by testing the type of the first arg and dispatch to memq/memql when possible. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 18 15:06:22 2019 Received: (at 36139) by debbugs.gnu.org; 18 Jun 2019 19:06:22 +0000 Received: from localhost ([127.0.0.1]:45619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdJR0-0005p1-M0 for submit@debbugs.gnu.org; Tue, 18 Jun 2019 15:06:22 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:54525) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdJQz-0005oj-6f for 36139@debbugs.gnu.org; Tue, 18 Jun 2019 15:06:21 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 694D581171; Tue, 18 Jun 2019 15:06:15 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 85AB580E0B; Tue, 18 Jun 2019 15:06:13 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1560884773; bh=3QRoqsUXPbWWwU2LEp/yXbMvzHY6tKfS20cdLavvryQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=B3ljEu3qdIqqUNfIFIJ4FI6N7J8+V+iEHr4KOyZ0BnqqmxU/u3cHwEaV/LN+5ELTs SYnb0brzshQ9vJzTTE61PrxK5HuFpHHpayxExpzOfAMMrEK5AMi8whkKJPSoN77vms PlvAj0wWNRfsY58AUVk8xNYQ2nc4hE6BpUjAJ0epWAh72p4VNFytuQsQt36q1RqgE7 K9/OOkl+lRLBfoV5OKELDFLGwGN/tHBludKzXG+oA5j91v382wHSADF9qT4BDxbifh c0Iq4QIni0I2zKCX4ynhmpjRe+bESuTKMypfnFKlvfswhSik66Gm2/8MiVbiaR7LRS hkBd+T916Wp2g== Received: from alfajor (unknown [157.52.10.58]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 37B171205E0; Tue, 18 Jun 2019 15:06:13 -0400 (EDT) From: Stefan Monnier To: Mattias =?windows-1252?Q?Engdeg=E5rd?= Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms Message-ID: References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> Date: Tue, 18 Jun 2019 15:06:12 -0400 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") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.007 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > Allow any mixture of `eq', `eql' and `equal', `memq', `memql' and > `member' in a switch-like `cond' to be compiled into a single switch. LGTM, Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 18 15:19:41 2019 Received: (at 36139) by debbugs.gnu.org; 18 Jun 2019 19:19:41 +0000 Received: from localhost ([127.0.0.1]:45628 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdJds-0006Bf-Se for submit@debbugs.gnu.org; Tue, 18 Jun 2019 15:19:41 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:27097) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdJdr-0006BS-7Y for 36139@debbugs.gnu.org; Tue, 18 Jun 2019 15:19:39 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3EFFF443B1B; Tue, 18 Jun 2019 15:19:33 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C7462443B17; Tue, 18 Jun 2019 15:19:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1560885567; bh=/hyzsWJWJZVwz7Xvl0jRpYkbcaJR06KaxenFNNXHUC0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=H/AE3UfcnyeQAuAuof/xHWAvHjT3d/w30thz84mcZ7zhx90zCaUi51evi7G8ibXZG 4RVZuRfabgUpdE279v0NjV888+giYnh27dkuDkTVBFAPL1f86LrPE+iOffCJYJEn4c SXLxKHO+p5aGfyhp/mjQB/7paon2OmBwOtxRyjYNfVNj6xYQZOx2nhVHjhHXRmyaoS L6JNMIFf0Gqq5qhz3S6p6o9uKTYBuHJvgB07bU8BI5cbjC8vU85EAH36CdMPc58pa5 OAvGGHxU44yOR6urrrplSJ0Vkf4MAVO6l4Y0UQs0g4MUdzDGPv5nxDsbIAujHCoAMT J/YCZ+PKNeAJw== Received: from alfajor (unknown [157.52.10.58]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 66BAB120BBB; Tue, 18 Jun 2019 15:19:27 -0400 (EDT) From: Stefan Monnier To: Mattias =?windows-1252?Q?Engdeg=E5rd?= Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms Message-ID: References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> Date: Tue, 18 Jun 2019 15:19:25 -0400 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") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > A single `cond' form can how be compiled to any number of switch ops, > interspersed with non-switch conditions in arbitrary ways. It can also be compiled to a bunch of switch ops only, right? (e.g. if it starts with a switch on `x` and then is followed by a switch on `y`) > + (and (> (length cases) 1) I think this `1` deserves a comment (IIRC it's the number of cases above which using a switch is expected to be faster than a sequence of tests). > + ;; Since `byte-compile-body' might increase `byte-compile-depth' > + ;; by 1, not preserving its value will cause it to potentially > + ;; increase by one for every clause body compiled, causing > + ;; depth/tag conflicts or violating asserts down the road. > + ;; To make sure `byte-compile-body' itself doesn't violate this, > + ;; we use `cl-assert'. > + (byte-compile-body body byte-compile--for-effect) > + (cl-assert (or (= byte-compile-depth init-depth) > + (= byte-compile-depth (1+ init-depth)))) IIRC the depth is altered depending on byte-compile--for-effect (if byte-compile--for-effect is non-nil when entering the function but nil afterwards, depth should be identical, and it should be increased by 1 otherwise), so we should be able to tighten this assertion to replace the `or` with an `if`. Other than that, the patch looks fine to me. Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 19 05:25:54 2019 Received: (at 36139) by debbugs.gnu.org; 19 Jun 2019 09:25:54 +0000 Received: from localhost ([127.0.0.1]:46024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdWqo-0003IM-GN for submit@debbugs.gnu.org; Wed, 19 Jun 2019 05:25:54 -0400 Received: from mail71c50.megamailservers.eu ([91.136.10.81]:59484 helo=mail92c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdWqm-0003IB-U5 for 36139@debbugs.gnu.org; Wed, 19 Jun 2019 05:25:54 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1560936350; bh=rqhEvibikW9kYRao6+j5cdASsazicxtcHzsPVxWetoE=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=I03rbnAC/UhbOpSvchzxwLjYPW6TRgZYmjbkAnI+/5rEbZ/Jnv5Cna7fryyZZeJ7M eQfA11b+7rQf5XJaY92t1rENy1zCt/7A4m09E5+1Qseus378fhW8G9Hqa8xPDU9D9A eN5tFK2sYlWw/s1ti+ELZug5Q0ykpY23PXGQdw8c= Feedback-ID: mattiase@acm.or Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail92c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5J9PkGO010655; Wed, 19 Jun 2019 09:25:50 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: Date: Wed, 19 Jun 2019 11:25:45 +0200 Content-Transfer-Encoding: 7bit Message-Id: <16202DDE-6135-4A3F-923C-76BF23FDA363@acm.org> References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> To: Stefan Monnier X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0213.5D09FF9E.0095, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=LZQSFAXi c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=iRZporoAAAAA:8 a=LdombgwA13wsVppJFcQA:9 a=CjuIK1q_8ugA:10 a=NOBgFS-JBQ2l-kSd6-zu:22 X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) 18 juni 2019 kl. 20.48 skrev Stefan Monnier : > > 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. Thanks, I merged and pushed those two patches as one. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 19 05:30:12 2019 Received: (at 36139) by debbugs.gnu.org; 19 Jun 2019 09:30:12 +0000 Received: from localhost ([127.0.0.1]:46028 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdWuy-0003QE-2n for submit@debbugs.gnu.org; Wed, 19 Jun 2019 05:30:12 -0400 Received: from mail1422c50.megamailservers.eu ([91.136.14.22]:37946 helo=mail102c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdWuu-0003P3-Sy for 36139@debbugs.gnu.org; Wed, 19 Jun 2019 05:30:10 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1560936602; bh=AWJJEynfW8D6aru+puor5Ckgyf7Ev4tMZK5t8AWgPt8=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=Qr2AF+qx4CxX9eXjsorP0Pf9K5HSZ4prN/8eghcHhb8px1wHWCkAwPcziXyDU+7Sq vPMaNeMSEWHPir2KWKvQvB5PY80JlFlJRSPJfX3K3vpnc97zd//blhA+P6oDk+3VYq K7lXJVBCATIs+Y/jqLCeHovfPEGbcAPptYDqLqZs= Feedback-ID: mattiase@acm.or Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail102c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5J9U0gp007584; Wed, 19 Jun 2019 09:30:02 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: Date: Wed, 19 Jun 2019 11:30:00 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <3B9FC7ED-30CE-4714-8A4B-5986EDB67E71@acm.org> References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> To: Stefan Monnier X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0206.5D0A009A.0060, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=F7x5iJpN c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=iRZporoAAAAA:8 a=z1zzveY_27sos4A43sgA:9 a=CjuIK1q_8ugA:10 a=NOBgFS-JBQ2l-kSd6-zu:22 X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 18 juni 2019 kl. 21.03 skrev Stefan Monnier : >=20 > LGTM. The other direction is to just always use `member` > and speed up the implementation of `member` by testing the type of > the first arg and dispatch to memq/memql when possible. Thank you. I ended up pushing this patch on the grounds that it took = care of unfinished business in pcase (it did try to select which = function to use, just didn't go all the way). Speeding up `member' is, = of course, useful on its own. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 19 05:30:37 2019 Received: (at 36139) by debbugs.gnu.org; 19 Jun 2019 09:30:37 +0000 Received: from localhost ([127.0.0.1]:46031 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdWvN-0003Qx-EB for submit@debbugs.gnu.org; Wed, 19 Jun 2019 05:30:37 -0400 Received: from mail1426c50.megamailservers.eu ([91.136.14.26]:38156 helo=mail102c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdWvK-0003Qg-Tr for 36139@debbugs.gnu.org; Wed, 19 Jun 2019 05:30:36 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1560936628; bh=Tzp2xgL3UzL21G1zRr6fTe5lWEL3Y7XbuwyoOm1nCRI=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=GKAaNGABxoLyt2Mc7NH8X9rIeveXpvr0+EgTu17HlvkRrt4O05oczSm/fJOTlAfDz SULC6NldzvTltL4CT0lx9F6jxxhmahJi5+xKpg2Rkh35Wyd/mw3AChwQnLi/wSnQnw zl4QjQ30ml3YLzL3H8k1nNKJnNp8WyXyNIQOdQr4= Feedback-ID: mattiase@acm.or Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail102c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5J9U0gq007584; Wed, 19 Jun 2019 09:30:28 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: Date: Wed, 19 Jun 2019 11:30:27 +0200 Content-Transfer-Encoding: 7bit Message-Id: <0E9C3220-E668-4008-9272-68A3E34F1869@acm.org> References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> To: Stefan Monnier X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0206.5D0A00B4.002F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=F7x5iJpN c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=iRZporoAAAAA:8 a=j-iVQNMzVyM19aP8BAYA:9 a=CjuIK1q_8ugA:10 a=NOBgFS-JBQ2l-kSd6-zu:22 X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 18 juni 2019 kl. 21.06 skrev Stefan Monnier : > >> Allow any mixture of `eq', `eql' and `equal', `memq', `memql' and >> `member' in a switch-like `cond' to be compiled into a single switch. > > LGTM, Thank you, pushed. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 19 06:15:08 2019 Received: (at 36139) by debbugs.gnu.org; 19 Jun 2019 10:15:08 +0000 Received: from localhost ([127.0.0.1]:46050 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdXcS-0004Wx-2B for submit@debbugs.gnu.org; Wed, 19 Jun 2019 06:15:08 -0400 Received: from mail153c50.megamailservers.eu ([91.136.10.163]:56866 helo=mail50c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdXcP-0004Wm-BY for 36139@debbugs.gnu.org; Wed, 19 Jun 2019 06:15:06 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1560939303; bh=a1K51vvB6B0lt1kyljd75EBaQzYOqp5PZAfH7eJw74s=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=ME+LdwdBdrYVetEyhBhBsqkDQA9CVv2iFKSy1Moy9sqlSaf+hZ3HCu3wdAtNadgJx Egm/kQqkzrU8uco5WD3g4AAN2aH8ChBMTL6DrsTsdwEMEKRKln/t7q/9mGsJQovPc6 wKA9x4ktAMEaX992stUnw5SJY9zxdzGb+W3bYxeI= Feedback-ID: mattiase@acm.or Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail50c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5JAExFN002074; Wed, 19 Jun 2019 10:15:02 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: Date: Wed, 19 Jun 2019 12:14:58 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> To: Stefan Monnier X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0210.5D0A0B27.002F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=VLnzYeHX c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=iRZporoAAAAA:8 a=cfymPELf2vErCep-CmIA:9 a=gNkfDvhx2r9dFsPu:21 a=PWl-oVwAyZQiZ0ev:21 a=CjuIK1q_8ugA:10 a=NOBgFS-JBQ2l-kSd6-zu:22 X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) 18 juni 2019 kl. 21.19 skrev Stefan Monnier : >=20 >> A single `cond' form can how be compiled to any number of switch ops, >> interspersed with non-switch conditions in arbitrary ways. >=20 > It can also be compiled to a bunch of switch ops only, right? > (e.g. if it starts with a switch on `x` and then is followed by > a switch on `y`) Correct, and good catch. I rephrased the commit message. >> + (and (> (length cases) 1) >=20 > I think this `1` deserves a comment (IIRC it's the number of cases > above which using a switch is expected to be faster than a sequence of > tests). Agreed, but the condition comes from the existing code = (bytecomp.el:4180) where the number isn't motivated further either. I = just assumed it was chosen with at least some care. The ability to include multi-value cases in the switch makes the = condition a conservative choice: if it is a good decision for = single-value cases, it is definitely valid for multiple values per case. I added a comment stating the intent, but it's not a lot more than = restating the Lisp in English. >> + ;; Since `byte-compile-body' might increase = `byte-compile-depth' >> + ;; by 1, not preserving its value will cause it to = potentially >> + ;; increase by one for every clause body compiled, causing >> + ;; depth/tag conflicts or violating asserts down the road. >> + ;; To make sure `byte-compile-body' itself doesn't violate = this, >> + ;; we use `cl-assert'. >> + (byte-compile-body body byte-compile--for-effect) >> + (cl-assert (or (=3D byte-compile-depth init-depth) >> + (=3D byte-compile-depth (1+ init-depth)))) >=20 > IIRC the depth is altered depending on byte-compile--for-effect (if > byte-compile--for-effect is non-nil when entering the function but nil > afterwards, depth should be identical, and it should be increased by > 1 otherwise), so we should be able to tighten this assertion to = replace > the `or` with an `if`. I'll do that in a separate change then, because it seems to be = orthogonal to my changes. Brief experiments seem to indicate that the (byte-compile-body body byte-compile--for-effect) call does not seem to alter byte-compile--for-effect, but it does = increase depth by 1 iff byte-compile--for-effect is non-nil. > Other than that, the patch looks fine to me. Thanks for the review! Pushed to master. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 19 10:03:56 2019 Received: (at 36139) by debbugs.gnu.org; 19 Jun 2019 14:03:56 +0000 Received: from localhost ([127.0.0.1]:47257 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdbBq-0006Mw-08 for submit@debbugs.gnu.org; Wed, 19 Jun 2019 10:03:56 -0400 Received: from mail237c50.megamailservers.eu ([91.136.10.247]:40578 helo=mail56c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdbBl-0006Mf-Cp for 36139@debbugs.gnu.org; Wed, 19 Jun 2019 10:03:51 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1560953026; bh=AR1x56seI35v3nZjjrXzgMBUSP+6MMDjd1WVTWl9XOY=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=Ptbm0iPSMqczbqzhDEsCp2Rv9rQ0FzHeYQZNe/EKOe6tMmbV76HgcjwJQkZMlaJim QO9li0IQIcpmwzr5VLuTBVsTILclsOfIJAleJFUiQysDCLusj4Et6upG/uMJhxER8G 40mUcU/iBF1gt5G+egU+MATe9sKG7Q25Y1+oOBbU= Feedback-ID: mattiase@acm.or Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail56c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5JE3i3N016897; Wed, 19 Jun 2019 14:03:46 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Message-Id: <7A5D1F4E-5FA9-4F09-A4DA-97121DB4423E@acm.org> Content-Type: multipart/mixed; boundary="Apple-Mail=_1116A00A-5ADA-43F2-8806-E4734189D9BE" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms Date: Wed, 19 Jun 2019 16:03:43 +0200 In-Reply-To: To: Stefan Monnier References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0215.5D0A40C2.004F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=AeKf4UfG c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=iRZporoAAAAA:8 a=BFJcE_pEVChk1N6ocioA:9 a=CjuIK1q_8ugA:10 a=L1q3HPCLzy56V1OEp5YA:9 a=B2y7HmGcmWMA:10 a=NOBgFS-JBQ2l-kSd6-zu:22 X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 36139 Cc: 36139@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --Apple-Mail=_1116A00A-5ADA-43F2-8806-E4734189D9BE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 18 juni 2019 kl. 21.03 skrev Stefan Monnier : >=20 > LGTM. The other direction is to just always use `member` > and speed up the implementation of `member` by testing the type of > the first arg and dispatch to memq/memql when possible. Here is a patch that does some cheap static optimisations: equal/eql and = member/memql become eq and memq if constant symbols are involved. (Works = for me, bootstraps fine, etc.) I considered doing the same for equal->eql and member->memql. It turns = out that equal is faster than eql for numbers, since eql doesn't have = its own byte op. For the same reason, member is faster than memql for = lists of up to 5 elements (on this machine). While we could reduce equal = to eql for constant lists > 5 elements of only symbols and numbers, it's = perhaps more trouble than it's worth. --Apple-Mail=_1116A00A-5ADA-43F2-8806-E4734189D9BE Content-Disposition: attachment; filename=0001-Strength-reduce-equal-eql-member-and-memql.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Strength-reduce-equal-eql-member-and-memql.patch" Content-Transfer-Encoding: quoted-printable =46rom=20e5f3da7af6cc209d4b29378d41427937d8a32435=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Wed,=2019=20Jun=202019=2013:26:58=20+0200=0A= Subject:=20[PATCH]=20Strength-reduce=20`equal',=20`eql',=20`member'=20= and=20`memql'=0A=0AWhen=20comparing=20against=20symbols,=20turn=20= `equal'=20and=20`eql'=20into=20`eq',=0Aand=20`member'=20and=20`memql'=20= into=20`memq'.=0A=0A*=20lisp/emacs-lisp/byte-opt.el=20= (byte-optimizer--constant-symbol-p)=0A(byte-optimize-equal,=20= byte-optimize-member):=20New.=0A(member,=20memql,=20equal,=20eql):=20Use=20= new=20byte-optimizers.=0A---=0A=20lisp/emacs-lisp/byte-opt.el=20|=2035=20= ++++++++++++++++++++++++++++++++++-=0A=201=20file=20changed,=2034=20= insertions(+),=201=20deletion(-)=0A=0Adiff=20--git=20= a/lisp/emacs-lisp/byte-opt.el=20b/lisp/emacs-lisp/byte-opt.el=0Aindex=20= b0aa407c8b..ca08b2ce50=20100644=0A---=20a/lisp/emacs-lisp/byte-opt.el=0A= +++=20b/lisp/emacs-lisp/byte-opt.el=0A@@=20-834,6=20+834,36=20@@=20= byte-optimize-identity=0A=20=09=09=20=20=20=20=20=20=20(if=20(=3D=201=20= (length=20(cdr=20form)))=20""=20"s"))=0A=20=20=20=20=20form))=0A=20=0A= +(defun=20byte-optimizer--constant-symbol-p=20(expr)=0A+=20=20"Whether=20= EXPR=20is=20a=20constant=20symbol."=0A+=20=20(and=20(macroexp-const-p=20= expr)=20(symbolp=20(eval=20expr))))=0A+=0A+(defun=20byte-optimize-equal=20= (form)=0A+=20=20;;=20Replace=20`equal'=20or=20`eql'=20with=20`eq'=20if=20= at=20least=20one=20arg=20is=20a=20symbol.=0A+=20=20(if=20(=3D=20(length=20= (cdr=20form))=202)=0A+=20=20=20=20=20=20(let=20((form=20= (byte-optimize-binary-predicate=20form)))=0A+=20=20=20=20=20=20=20=20(if=20= (or=20(byte-optimizer--constant-symbol-p=20(nth=201=20form))=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20= (byte-optimizer--constant-symbol-p=20(nth=202=20form)))=0A+=20=20=20=20=20= =20=20=20=20=20=20=20(cons=20'eq=20(cdr=20form))=0A+=20=20=20=20=20=20=20= =20=20=20form))=0A+=20=20=20=20;;=20Arity=20errors=20reported=20= elsewhere.=0A+=20=20=20=20form))=0A+=0A+(defun=20byte-optimize-member=20= (form)=0A+=20=20;;=20Replace=20`member'=20or=20`memql'=20with=20`memq'=20= if=20the=20first=20arg=20is=20a=20symbol,=0A+=20=20;;=20or=20the=20= second=20arg=20is=20a=20list=20of=20symbols.=0A+=20=20(if=20(=3D=20= (length=20(cdr=20form))=202)=0A+=20=20=20=20=20=20(if=20(or=20= (byte-optimizer--constant-symbol-p=20(nth=201=20form))=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(let=20((arg2=20(nth=202=20form)))=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(and=20(macroexp-const-p=20arg2)=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(let=20= ((listval=20(eval=20arg2)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(and=20(listp=20listval)=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(not=20= (memq=20nil=20(mapcar=20#'symbolp=20listval))))))))=0A+=20=20=20=20=20=20= =20=20=20=20(cons=20'memq=20(cdr=20form))=0A+=20=20=20=20=20=20=20=20= form)=0A+=20=20=20=20;;=20Arity=20errors=20reported=20elsewhere.=0A+=20=20= =20=20form))=0A+=0A=20(defun=20byte-optimize-memq=20(form)=0A=20=20=20;;=20= (memq=20foo=20'(bar))=20=3D>=20(and=20(eq=20foo=20'bar)=20'(bar))=0A=20=20= =20(if=20(/=3D=20(length=20(cdr=20form))=202)=0A@@=20-852,6=20+882,8=20= @@=20byte-optimize-memq=0A=20=0A=20(put=20'identity=20'byte-optimizer=20= 'byte-optimize-identity)=0A=20(put=20'memq=20'byte-optimizer=20= 'byte-optimize-memq)=0A+(put=20'memql=20=20'byte-optimizer=20= 'byte-optimize-member)=0A+(put=20'member=20'byte-optimizer=20= 'byte-optimize-member)=0A=20=0A=20(put=20'+=20=20=20'byte-optimizer=20= 'byte-optimize-plus)=0A=20(put=20'*=20=20=20'byte-optimizer=20= 'byte-optimize-multiply)=0A@@=20-862,7=20+894,8=20@@=20= byte-optimize-memq=0A=20=0A=20(put=20'=3D=20=20=20'byte-optimizer=20= 'byte-optimize-binary-predicate)=0A=20(put=20'eq=20=20'byte-optimizer=20= 'byte-optimize-binary-predicate)=0A-(put=20'equal=20=20=20= 'byte-optimizer=20'byte-optimize-binary-predicate)=0A+(put=20'eql=20=20=20= 'byte-optimizer=20'byte-optimize-equal)=0A+(put=20'equal=20= 'byte-optimizer=20'byte-optimize-equal)=0A=20(put=20'string=3D=20= 'byte-optimizer=20'byte-optimize-binary-predicate)=0A=20(put=20= 'string-equal=20'byte-optimizer=20'byte-optimize-binary-predicate)=0A=20=0A= --=20=0A2.20.1=20(Apple=20Git-117)=0A=0A= --Apple-Mail=_1116A00A-5ADA-43F2-8806-E4734189D9BE-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 28 16:51:12 2019 Received: (at 36139-done) by debbugs.gnu.org; 28 Jun 2019 20:51:12 +0000 Received: from localhost ([127.0.0.1]:43103 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgxpw-0003T0-0V for submit@debbugs.gnu.org; Fri, 28 Jun 2019 16:51:12 -0400 Received: from mail176c50.megamailservers.eu ([91.136.10.186]:35552 helo=mail37c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgxpt-0003Sn-6f for 36139-done@debbugs.gnu.org; Fri, 28 Jun 2019 16:51:10 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1561755066; bh=dYF/5ySGvWxn7kkFIw5FJbeXCW9/e+Tj04hXgOt1EpU=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=jLKqCOc6E3CQIcIo6Hgz7pabfaaKoP/19Z5OEFEZaahmmrqOj0LuYatTXUXQGPnAK weD0p5poYLEeGFSwnCTD3G/Uo9yj1ScPDZZelCcso1P486TQm9kFyLkTAEWsuD6ZzX hy1c7UXjv906QW9fOYz3skF5vpdej5y0KL/WzVSc= Feedback-ID: mattiase@acm.or Received: from [192.168.1.65] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail37c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5SKp2Sp005888; Fri, 28 Jun 2019 20:51:05 +0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36139: [PATCH] Make better use of the switch op in cond forms From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: <7A5D1F4E-5FA9-4F09-A4DA-97121DB4423E@acm.org> Date: Fri, 28 Jun 2019 22:51:02 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <75B08E98-57B8-4B60-9931-C048B5C451E6@acm.org> References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> <7A5D1F4E-5FA9-4F09-A4DA-97121DB4423E@acm.org> To: Stefan Monnier X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B020F.5D167DBA.0001, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=Mot8FVSe c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=IkcTkHD0fZMA:10 a=N54-gffFAAAA:8 a=6z37DFG6Rd5VU_by-V0A:9 a=QEXdDO2ut3YA:10 a=6l0D2HzqY3Epnrm8mE3f:22 X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 36139-done Cc: 36139-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) 19 juni 2019 kl. 16.03 skrev Mattias Engdeg=C3=A5rd : >=20 > Here is a patch that does some cheap static optimisations: equal/eql = and member/memql become eq and memq if constant symbols are involved. = (Works for me, bootstraps fine, etc.) After dithering a bit and testing alternatives, I pushed a tweaked = version of that patch; there seemed to be little reason not to. From unknown Fri Jun 13 10:33:37 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 27 Jul 2019 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator