bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#27584: 26.0.50; alist-get: Add optional arg TESTFN


From: Eli Zaretskii
Subject: bug#27584: 26.0.50; alist-get: Add optional arg TESTFN
Date: Sat, 08 Jul 2017 10:14:54 +0300

> From: Tino Calancha <address@hidden>
> Date: Sat, 8 Jul 2017 16:02:12 +0900 (JST)
> cc: Nicolas Petton <address@hidden>, address@hidden, 
>     address@hidden, Tino Calancha <address@hidden>
> 
> > 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?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]