From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Nicolas Petton Newsgroups: gmane.emacs.bugs Subject: bug#27584: 26.0.50; alist-get: Add optional arg TESTFN Date: Sat, 08 Jul 2017 13:29:20 +0200 Message-ID: <87lgnz4167.fsf@petton.fr> 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: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1499513422 8008 195.159.176.226 (8 Jul 2017 11:30:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 8 Jul 2017 11:30:22 +0000 (UTC) Cc: 27584@debbugs.gnu.org, monnier@iro.umontreal.ca, Tino Calancha To: Tino Calancha , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 08 13:30:15 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 1dTnwF-0001Ql-0z for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Jul 2017 13:30:15 +0200 Original-Received: from localhost ([::1]:60663 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTnwD-0000Ob-Sm for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Jul 2017 07:30:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTnw7-0000Ml-Jp for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 07:30:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dTnw2-00014I-O3 for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 07:30:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54700) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dTnw2-00014E-KK for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 07:30:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dTnw2-0000QN-Cu for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2017 07:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Nicolas Petton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 Jul 2017 11:30: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.14995133731578 (code B ref 27584); Sat, 08 Jul 2017 11:30:02 +0000 Original-Received: (at 27584) by debbugs.gnu.org; 8 Jul 2017 11:29:33 +0000 Original-Received: from localhost ([127.0.0.1]:57377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTnvZ-0000PO-4c for submit@debbugs.gnu.org; Sat, 08 Jul 2017 07:29:33 -0400 Original-Received: from petton.fr ([89.234.186.68]:33140) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTnvX-0000P9-5M for 27584@debbugs.gnu.org; Sat, 08 Jul 2017 07:29:32 -0400 In-Reply-To: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=petton.fr; s=mail; t=1499513364; bh=9V+XmBF62sk+Kr8FZCYVYkc4zSXb8Urv/ohL52sQ0vY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:MIME-Version:Content-Type; b=WlhhmS8uKj32zMt8WLcTWWb+OGKVjPZkMGtb35I+Pa801PHY1rwmDs/VA5YzmyMA5VT07/v6wMtw9i3Fdmpb4CLYcODplMjDCz9nCcWcm2XXNGAYwhhegAXnMAUdUPT0r73Rg0U6XQm4Z0k+yaihSkFvQyjEb1aCvqfMC4Fj2SU= 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:134331 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Tino Calancha writes: > Do you mean something like this? > > { > Lisp_Object tail =3D list; > Lisp_Object fn =3D NILP (testfn) ? Qequal : testfn; > FOR_EACH_TAIL (tail) > { > Lisp_Object car =3D 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=20 > ;; efficient than just using Fequal, right? I like your version more, but I also thought that it would be slower for the default case. I ran benchmark-run with the first version: (setq alist (mapcar (lambda (e) `(,(intern e) . ,e)) (locate-file-completion-table load-path (get-load-suffixes) "" nil t))) =20=20=20=20=20=20 (benchmark-run (assoc 'absent alist)) (0.00023356 0 0.0) (0.00016584 0 0.0) (0.000165243 0 0.0) (0.000164741 0 0.0) (0.000240754 0 0.0) (0.000104102 0 0.0) and with your version: (0.000556587 0 0.0) (0.000238677 0 0.0) (0.000498506 0 0.0) (0.000527675 0 0.0) (0.00064989 0 0.0) (0.000520543 0 0.0) Cheers, Nico --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJZYMIQAAoJECM1h6R8IHkQ0gYH/Azy2dS7wnYIS854P7h9gYSK nl6o0eN1e9fqaRQyuvtsJ6spUhq80q5Evh/ZnOb5yZrNOkac6wp4W4ccrLaHNAT6 ILFo+bTUYd6u/jmdd4+CjQFYIMrQHHWRxKBPN3Vm7PUEbCvEQKB7LO90i2ggGykE e8DITFhRteLt6toks6sYDKHcFjS5taThBcxwnO4LSTq56zFdDwIaa6fcdgNLnywG 0aVmnZJS1DcthPeCO1MMrPHPLosO1v+Pl6lAMDuoCQvbaSfa+6kaxazLEGX53z17 LWw9mRNP0jFoTZM3mD0LugzrKrK8xHs9kvbptN87mxD4HymF0yrh+iTqcCwmBvI= =QmjV -----END PGP SIGNATURE----- --=-=-=--