[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27584: 26.0.50; alist-get: Add optional arg TESTFN
From: |
Nicolas Petton |
Subject: |
bug#27584: 26.0.50; alist-get: Add optional arg TESTFN |
Date: |
Sat, 08 Jul 2017 13:29:20 +0200 |
Tino Calancha <tino.calancha@gmail.com> writes:
> 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?
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)))
(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
signature.asc
Description: PGP signature
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, (continued)
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Nicolas Petton, 2017/07/08
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Eli Zaretskii, 2017/07/08
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Tino Calancha, 2017/07/09
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Nicolas Petton, 2017/07/09
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Nicolas Petton, 2017/07/11
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Tino Calancha, 2017/07/11
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Michael Heerdegen, 2017/07/12
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Tino Calancha, 2017/07/14
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Nicolas Petton, 2017/07/14
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Tino Calancha, 2017/07/17
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN,
Nicolas Petton <=