From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#36139: [PATCH] Make better use of the switch op in cond forms Date: Tue, 18 Jun 2019 15:19:25 -0400 Message-ID: References: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="62122"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 36139@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 18 21:21:24 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hdJfY-000G49-3b for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Jun 2019 21:21:24 +0200 Original-Received: from localhost ([::1]:33032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdJfX-0006cV-2c for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Jun 2019 15:21:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40203) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdJeI-0006bl-QU for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 15:20:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdJeG-00053g-2a for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 15:20:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60317) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hdJeE-00050q-BQ for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 15:20:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hdJeE-0006CU-5b for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 15:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Jun 2019 19:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36139 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 36139-submit@debbugs.gnu.org id=B36139.156088558123792 (code B ref 36139); Tue, 18 Jun 2019 19:20:02 +0000 Original-Received: (at 36139) by debbugs.gnu.org; 18 Jun 2019 19:19:41 +0000 Original-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 Original-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 Original-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) Original-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== Original-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) In-Reply-To: <68467ACF-DA49-4EBA-BA3B-7339DB22A456@acm.org> ("Mattias \=\?windows-1252\?Q\?Engdeg\=E5rd\=22's\?\= message of "Sat, 8 Jun 2019 16:40:07 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:160795 Archived-At: > 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