From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#27584: 26.0.50; alist-get: Add optional arg TESTFN Date: Sat, 08 Jul 2017 10:14:54 +0300 Message-ID: <83lgnzl7rl.fsf@gnu.org> References: <87tw2rva7v.fsf@calancha-pc> <87mv8j6y1z.fsf@petton.fr> <87y3s2m76v.fsf@calancha-pc> <8760f562bo.fsf@petton.fr> <877ezk3g4p.fsf@calancha-pc> <874luovf7a.fsf@petton.fr> <87shi8tzkr.fsf@petton.fr> <8737a858so.fsf@petton.fr> <83wp7jl9uf.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1499498179 13644 195.159.176.226 (8 Jul 2017 07:16:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 8 Jul 2017 07:16:19 +0000 (UTC) Cc: nicolas@petton.fr, monnier@iro.umontreal.ca, 27584@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 08 09:16:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTjyI-0002yG-Ai for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Jul 2017 09:16:06 +0200 Original-Received: from localhost ([::1]:60149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTjyN-0007ph-OL for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Jul 2017 03:16:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTjyI-0007pc-2x for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 03:16:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dTjyE-0008KK-NZ for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 03:16:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54587) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dTjyE-0008KG-Ja for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 03:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dTjyE-000378-EK for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 03:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 Jul 2017 07:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27584 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27584-submit@debbugs.gnu.org id=B27584.149949811511911 (code B ref 27584); Sat, 08 Jul 2017 07:16:02 +0000 Original-Received: (at 27584) by debbugs.gnu.org; 8 Jul 2017 07:15:15 +0000 Original-Received: from localhost ([127.0.0.1]:57263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTjxT-000363-Cd for submit@debbugs.gnu.org; Sat, 08 Jul 2017 03:15:15 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49873) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTjxR-00035o-1U for 27584@debbugs.gnu.org; Sat, 08 Jul 2017 03:15:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dTjxI-0007yg-T2 for 27584@debbugs.gnu.org; Sat, 08 Jul 2017 03:15:07 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:36988) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTjxI-0007yb-PC; Sat, 08 Jul 2017 03:15:04 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1234 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dTjxH-0002mz-Q2; Sat, 08 Jul 2017 03:15:04 -0400 In-reply-to: (message from Tino Calancha on Sat, 8 Jul 2017 16:02:12 +0900 (JST)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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: 208.118.235.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:134325 Archived-At: > From: Tino Calancha > Date: Sat, 8 Jul 2017 16:02:12 +0900 (JST) > cc: Nicolas Petton , monnier@iro.umontreal.ca, > 27584@debbugs.gnu.org, Tino Calancha > > > Bonus points for simplifying the code by determining TESTFN up front, > > then having only one of the above two clauses. > Do you mean something like this? > > { > Lisp_Object tail = list; > Lisp_Object fn = NILP (testfn) ? Qequal : testfn; > FOR_EACH_TAIL (tail) > { > Lisp_Object car = XCAR (tail); > if (CONSP (car) && !NILP (call2 (fn, (XCAR (car)), key))) > return car; > } > > CHECK_LIST_END (tail, list); > return Qnil; > } That's one way, yes. But not necessarily the one I had in mind. > ;; This is shorter but now the default case, because the call2, is less > ;; efficient than just using Fequal, right? Is it? Did you time it?