From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#27584: 26.0.50; alist-get: Add optional arg TESTFN Date: Sat, 8 Jul 2017 16:02:12 +0900 (JST) Message-ID: 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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1499497396 31460 195.159.176.226 (8 Jul 2017 07:03:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 8 Jul 2017 07:03:16 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: Nicolas Petton , 27584@debbugs.gnu.org, monnier@iro.umontreal.ca, Tino Calancha To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 08 09:03:10 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 1dTjll-0007oX-8M for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Jul 2017 09:03:09 +0200 Original-Received: from localhost ([::1]:60104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTjlq-0005Qs-Gr for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Jul 2017 03:03:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTjlj-0005Qb-91 for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 03:03:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dTjle-0004Eq-DU for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 03:03:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54577) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dTjle-0004Ek-AK for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 03:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dTjle-0002pG-1X for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 03:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 Jul 2017 07:03:01 +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.149949734510820 (code B ref 27584); Sat, 08 Jul 2017 07:03:01 +0000 Original-Received: (at 27584) by debbugs.gnu.org; 8 Jul 2017 07:02:25 +0000 Original-Received: from localhost ([127.0.0.1]:57254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTjl2-0002oR-TP for submit@debbugs.gnu.org; Sat, 08 Jul 2017 03:02:25 -0400 Original-Received: from mail-pf0-f180.google.com ([209.85.192.180]:34773) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTjl0-0002oF-VM for 27584@debbugs.gnu.org; Sat, 08 Jul 2017 03:02:23 -0400 Original-Received: by mail-pf0-f180.google.com with SMTP id q85so26814394pfq.1 for <27584@debbugs.gnu.org>; Sat, 08 Jul 2017 00:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=3zfWEelsLyKE5GvwAKoneLTq2obhzulgEq8+xyoogko=; b=IjO5/vAHqq7L/Br8Z56/m8Qx/Ihp/tDsC1Rla4rwuQHW6kzOro5GlaaF8QHH20MKUi Zn51SdEbrSReUwHhOtXRMnbErUCFTKQITqHoN9E48WWh9ZAPW+BdKZpwUO2GINVkPAGp GWokrFBauFWWGtaoxN2aLOuHKWepBc+S00q2dk6GWKMR6r3RfyAfl+0ItAIKSeUzfY6T 6M0UyIr0FWbgvBlLMFnzQIJHgmTL0qnPycz8acCE/NNGgzQZW9f4nkkBpr9nCPma2M+F fcyzVKi0toRkm2QGDaOd/yVQp3guKjHBDNz8hh7fYJZxuBBzOkA8p5SRn4LQ5mC1rGJb MxqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=3zfWEelsLyKE5GvwAKoneLTq2obhzulgEq8+xyoogko=; b=kblUZVVvD6kDPowfwrvEmlBRfwpHKjogn4tlC1o6TU7zZmJNIkuCjkKWP203NZVko5 0DijoIthgRDpIVrYJn64UTT5dWyWertNVQGTQPiA8EcMWOQ98QBvTtz2GzXyvYUfaQG7 oOjc0wBtKtATnX6wRZvMU8PV1UgKJKLaRQ8OU9juhXutnbxDPY1KrIfJqoGZvLhonSFs osV4mJPdhIKvyec8vRwHB8S492XRz005CXzk6poLtoynH2HrNiL4MdSPx/hk5EokOWhl 2gzezfnGegJfQIHdlzDSynFKoh+GBasotjs23JOUxmFrAlZjUY0Zrt/TGgHSAm/r5NPZ B2rw== X-Gm-Message-State: AIVw110nNAvKPvgz2BV6r4nLW4a0USXsysgCLkB30+/g6uP6Ycjr8jTV 1gPZdba00UUJuQ== X-Received: by 10.84.241.198 with SMTP id t6mr7274843plm.48.1499497335815; Sat, 08 Jul 2017 00:02:15 -0700 (PDT) Original-Received: from calancha-pc (170.224.128.101.dy.bbexcite.jp. [101.128.224.170]) by smtp.gmail.com with ESMTPSA id o84sm12920832pfj.109.2017.07.08.00.02.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Jul 2017 00:02:15 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <83wp7jl9uf.fsf@gnu.org> 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:134323 Archived-At: On Sat, 8 Jul 2017, Eli Zaretskii wrote: >> From: Nicolas Petton >> Date: Fri, 07 Jul 2017 21:47:03 +0200 >> Cc: 27584@debbugs.gnu.org, Tino Calancha >> >> + if (NILP (testfn)) >> + { >> + if (CONSP (car) >> + && (EQ (XCAR (car), key) || !NILP (Fequal (XCAR (car), key)))) >> + return car; >> + } >> + else if (CONSP (car) && (!NILP (call2 (testfn, (XCAR (car)), key)))) >> + { >> + return car; >> + } > > No need for braces when there's only one line to enclose. > Also, no need for parentheses around "!NILP (...)". > > 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; } ;; This is shorter but now the default case, because the call2, is less ;; efficient than just using Fequal, right?