From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#35868: [PATCH] `memql' does not work for bignums Date: Thu, 30 May 2019 15:01:19 -0700 Organization: UCLA Computer Science Department Message-ID: <615e1634-1167-abc2-0f16-2c84274d47ba@cs.ucla.edu> References: <79AE2738-3B42-410A-AA9A-F0FDE7865162@acm.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------3FBF2ACCB28F47A5113A666B" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="104839"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 Cc: 35868-done@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 Fri May 31 00:02:32 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.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hWT81-000R89-Nr for geb-bug-gnu-emacs@m.gmane.org; Fri, 31 May 2019 00:02:29 +0200 Original-Received: from localhost ([127.0.0.1]:59607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWT7x-0007Z7-Ps for geb-bug-gnu-emacs@m.gmane.org; Thu, 30 May 2019 18:02:25 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWT7o-0007YV-SV for bug-gnu-emacs@gnu.org; Thu, 30 May 2019 18:02:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWT7e-000765-Nk for bug-gnu-emacs@gnu.org; Thu, 30 May 2019 18:02:08 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48901) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWT7b-00073N-0u for bug-gnu-emacs@gnu.org; Thu, 30 May 2019 18:02:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hWT7a-00058a-Th for bug-gnu-emacs@gnu.org; Thu, 30 May 2019 18:02:02 -0400 In-Reply-To: <79AE2738-3B42-410A-AA9A-F0FDE7865162@acm.org> Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 May 2019 22:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 35868 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 35868@debbugs.gnu.org, eggert@cs.ucla.edu, mattiase@acm.org Original-Received: via spool by 35868-done@debbugs.gnu.org id=D35868.155925369119695 (code D ref 35868); Thu, 30 May 2019 22:02:02 +0000 Original-Received: (at 35868-done) by debbugs.gnu.org; 30 May 2019 22:01:31 +0000 Original-Received: from localhost ([127.0.0.1]:34212 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hWT74-00057b-HR for submit@debbugs.gnu.org; Thu, 30 May 2019 18:01:30 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55400) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hWT70-00057J-Vl for 35868-done@debbugs.gnu.org; Thu, 30 May 2019 18:01:28 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 953AD160849; Thu, 30 May 2019 15:01:20 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id WgvtIkitZ90U; Thu, 30 May 2019 15:01:19 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7041216087F; Thu, 30 May 2019 15:01:19 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KW8fKskc-TJJ; Thu, 30 May 2019 15:01:19 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 4AE4B160878; Thu, 30 May 2019 15:01:19 -0700 (PDT) Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTYp5bltF3WYDz1Ygd7gx07Auwp7iw7eNvnoDTAl KAl8KYDZzbDNCQGEbpY3efZIvPdeI+FWQN4W+kghy+P6au6PrIIhYraeua7XDdb2LS1en3Ss mE3QjqfRqI/A2ue8JMwsvXe/WK38Ezs6x74iTaqI3AFH6ilAhDqpMnd/msSESNFt76DiO1ZK QMr9amVPknjfPmJISqdhgB1DlEdw34sROf6V8mZw0xfqT6PKE46LcFefzs0kbg4GORf8vjG2 Sf1tk5eU8MBiyN/bZ03bKNjNYMpODDQQwuP84kYLkX2wBxxMAhBxwbDVZudzxDZJ1C2VXujC OJVxq2kljBM9ETYuUGqd75AW2LXrLw6+MuIsHFAYAgRr7+KcwDgBAfwhPBYX34nSSiHlmLC+ KaHLeCLF5ZI2vKm3HEeCTtlOg7xZEONgwzL+fdKo+D6SoC8RRxJKs8a3sVfI4t6CnrQzvJbB n6gxdgCu5i29J1QCYrCYvql2UyFPAK+do99/1jOXT4m2836j1wARAQABzSBQYXVsIEVnZ2Vy dCA8ZWdnZXJ0QGNzLnVjbGEuZWR1PsLBfgQTAQIAKAUCTIByZAIbAwUJEswDAAYLCQgHAwIG FQgCCQoLBBYCAwECH Content-Language: en-US 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:159949 Archived-At: This is a multi-part message in MIME format. --------------3FBF2ACCB28F47A5113A666B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for the bug report and fix. I installed it into master, followed by the attached performance tweaks. --------------3FBF2ACCB28F47A5113A666B Content-Type: text/x-patch; name="0001-Improve-eq1-memql-performance.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Improve-eq1-memql-performance.patch" >From 24a58620cb8ce4aa11e2428d86e58911e7975aeb Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 30 May 2019 14:57:21 -0700 Subject: [PATCH] Improve eq1/memql performance * src/fns.c (Fmemql, Feql): Inline to tweak performance. --- src/fns.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/fns.c b/src/fns.c index da830a9000..cb47b818f1 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1521,7 +1521,7 @@ DEFUN ("elt", Felt, Selt, 2, 2, 0, EMACS_UINT word[WORDS_PER_DOUBLE]; }; -/* Return true if X and Y are the same floating-point value. +/* Return true if the floats X and Y have the same value. This looks at X's and Y's representation, since (unlike '==') it returns true if X and Y are the same NaN. */ static bool @@ -1567,32 +1567,32 @@ DEFUN ("memql", Fmemql, Smemql, 2, 2, 0, The value is actually the tail of LIST whose car is ELT. */) (Lisp_Object elt, Lisp_Object list) { + Lisp_Object tail = list; + if (FLOATP (elt)) { - Lisp_Object tail = list; FOR_EACH_TAIL (tail) { Lisp_Object tem = XCAR (tail); if (FLOATP (tem) && same_float (elt, tem)) return tail; } - CHECK_LIST_END (tail, list); - return Qnil; } else if (BIGNUMP (elt)) { - Lisp_Object tail = list; FOR_EACH_TAIL (tail) { Lisp_Object tem = XCAR (tail); - if (equal_no_quit (elt, tem)) + if (BIGNUMP (tem) + && mpz_cmp (XBIGNUM (elt)->value, XBIGNUM (tem)->value) == 0) return tail; } - CHECK_LIST_END (tail, list); - return Qnil; } else return Fmemq (elt, list); + + CHECK_LIST_END (tail, list); + return Qnil; } DEFUN ("assq", Fassq, Sassq, 2, 2, 0, @@ -2301,7 +2301,9 @@ DEFUN ("eql", Feql, Seql, 2, 2, 0, if (FLOATP (obj1)) return FLOATP (obj2) && same_float (obj1, obj2) ? Qt : Qnil; else if (BIGNUMP (obj1)) - return equal_no_quit (obj1, obj2) ? Qt : Qnil; + return ((BIGNUMP (obj2) + && mpz_cmp (XBIGNUM (obj1)->value, XBIGNUM (obj2)->value) == 0) + ? Qt : Qnil); else return EQ (obj1, obj2) ? Qt : Qnil; } -- 2.21.0 --------------3FBF2ACCB28F47A5113A666B--