From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Newsgroups: gmane.lisp.guile.bugs Subject: bug#41354: equal? has no sensible code path for symbols Date: Fri, 29 May 2020 10:05:06 +0200 Message-ID: <87ftbj6ua5.fsf@gnu.org> References: <87v9kuzvht.fsf@fencepost.gnu.org> <875zchjen4.fsf@gnu.org> <87o8q9cddl.fsf@fencepost.gnu.org> <87367kavs1.fsf@gnu.org> <87blm8c8c3.fsf@fencepost.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="47836"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: 41354@debbugs.gnu.org To: David Kastrup Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Fri May 29 10:06:07 2020 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jea1n-000CJk-0D for guile-bugs@m.gmane-mx.org; Fri, 29 May 2020 10:06:07 +0200 Original-Received: from localhost ([::1]:34540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jea1l-0001uO-Gm for guile-bugs@m.gmane-mx.org; Fri, 29 May 2020 04:06:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jea1i-0001rM-3X for bug-guile@gnu.org; Fri, 29 May 2020 04:06:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jea1h-0001YZ-Qn for bug-guile@gnu.org; Fri, 29 May 2020 04:06:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jea1h-0001F3-MB for bug-guile@gnu.org; Fri, 29 May 2020 04:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 29 May 2020 08:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41354 X-GNU-PR-Package: guile Original-Received: via spool by 41354-submit@debbugs.gnu.org id=B41354.15907395174713 (code B ref 41354); Fri, 29 May 2020 08:06:01 +0000 Original-Received: (at 41354) by debbugs.gnu.org; 29 May 2020 08:05:17 +0000 Original-Received: from localhost ([127.0.0.1]:53717 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jea0y-0001Dx-Lg for submit@debbugs.gnu.org; Fri, 29 May 2020 04:05:16 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48300) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jea0w-0001Dk-SD for 41354@debbugs.gnu.org; Fri, 29 May 2020 04:05:15 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:50638) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jea0r-00013j-Mg for 41354@debbugs.gnu.org; Fri, 29 May 2020 04:05:09 -0400 Original-Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41832 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jea0q-0007XN-Rk; Fri, 29 May 2020 04:05:09 -0400 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 11 Prairial an 228 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu In-Reply-To: <87blm8c8c3.fsf@fencepost.gnu.org> (David Kastrup's message of "Thu, 28 May 2020 18:50:20 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9789 Archived-At: Hi, David Kastrup skribis: > Ludovic Court=C3=A8s writes: [...] >> Thus we could go with the patch below, though I doubt it would make a >> measurable difference (and it actually adds tests for other cases). > > It made a considerable measurable difference in LilyPond You measured with and without the patch I sent? Or something else? >> diff --git a/libguile/eq.c b/libguile/eq.c >> index 627d6f09b..16c5bfb3f 100644 >> --- a/libguile/eq.c >> +++ b/libguile/eq.c >> @@ -303,6 +303,8 @@ scm_equal_p (SCM x, SCM y) >> return SCM_BOOL_F; >> if (SCM_IMP (y)) >> return SCM_BOOL_F; >> + if (scm_is_symbol (x) || scm_is_symbol (y)) >> + return SCM_BOOL_F; >> if (scm_is_pair (x) && scm_is_pair (y)) >> { >> if (scm_is_false (scm_equal_p (SCM_CAR (x), SCM_CAR (y)))) >> > > Yes, that looks reasonable. scm_is_symbol checks some tag subset that > the code for equal_p later looks at closer as well: if you worry about > the extra cost of the scm_is_symbol check, one could try folding the > symbol check into that later code passage, which would slow down the > symbol check and effect the more costly fallbacks less. But since those > fallbacks _are_ more costly, I doubt it would be worth the trouble. Looking at eq.c, I don=E2=80=99t see what =E2=80=9Ccostly fallbacks=E2=80= =9D you=E2=80=99re referring to. For a symbol, AIUI, we end up here: switch (SCM_TYP7 (x)) { default: /* Check equality between structs of equal type (see cell-type test a= bove). */ if (SCM_STRUCTP (x)) { if (SCM_INSTANCEP (x)) goto generic_equal; else return scm_i_struct_equalp (x, y); } break; // <- here, meaning we return SCM_BOOL_F All the checks leading to this line are type tag comparisons. Am I overlooking something? Thanks, Ludo=E2=80=99.