emacs-diffs
[Top][All Lists]
Advanced

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

master a0f7d81a8d: * src/fns.c (mapcar1): Test types in rough order of l


From: Mattias Engdegård
Subject: master a0f7d81a8d: * src/fns.c (mapcar1): Test types in rough order of likelyhood.
Date: Thu, 16 Jun 2022 11:24:34 -0400 (EDT)

branch: master
commit a0f7d81a8dfefc20a283585dca3a37240a2b7a9a
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    * src/fns.c (mapcar1): Test types in rough order of likelyhood.
---
 src/fns.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/fns.c b/src/fns.c
index 97af39c416..4df944507c 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2757,20 +2757,26 @@ usage: (nconc &rest LISTS)  */)
 static EMACS_INT
 mapcar1 (EMACS_INT leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq)
 {
-  if (VECTORP (seq) || COMPILEDP (seq))
+  if (NILP (seq))
+    return 0;
+  else if (CONSP (seq))
     {
+      Lisp_Object tail = seq;
       for (ptrdiff_t i = 0; i < leni; i++)
        {
-         Lisp_Object dummy = call1 (fn, AREF (seq, i));
+         if (! CONSP (tail))
+           return i;
+         Lisp_Object dummy = call1 (fn, XCAR (tail));
          if (vals)
            vals[i] = dummy;
+         tail = XCDR (tail);
        }
     }
-  else if (BOOL_VECTOR_P (seq))
+  else if (VECTORP (seq) || COMPILEDP (seq))
     {
-      for (EMACS_INT i = 0; i < leni; i++)
+      for (ptrdiff_t i = 0; i < leni; i++)
        {
-         Lisp_Object dummy = call1 (fn, bool_vector_ref (seq, i));
+         Lisp_Object dummy = call1 (fn, AREF (seq, i));
          if (vals)
            vals[i] = dummy;
        }
@@ -2788,17 +2794,14 @@ mapcar1 (EMACS_INT leni, Lisp_Object *vals, Lisp_Object 
fn, Lisp_Object seq)
            vals[i_before] = dummy;
        }
     }
-  else   /* Must be a list, since Flength did not get an error */
+  else
     {
-      Lisp_Object tail = seq;
-      for (ptrdiff_t i = 0; i < leni; i++)
+      eassert (BOOL_VECTOR_P (seq));
+      for (EMACS_INT i = 0; i < leni; i++)
        {
-         if (! CONSP (tail))
-           return i;
-         Lisp_Object dummy = call1 (fn, XCAR (tail));
+         Lisp_Object dummy = call1 (fn, bool_vector_ref (seq, i));
          if (vals)
            vals[i] = dummy;
-         tail = XCDR (tail);
        }
     }
 



reply via email to

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