emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 0dfd9a6 1/3: Simplify make-list implementation


From: Paul Eggert
Subject: [Emacs-diffs] master 0dfd9a6 1/3: Simplify make-list implementation
Date: Thu, 26 Jan 2017 05:25:42 +0000 (UTC)

branch: master
commit 0dfd9a69186e12e53b8aa759c47b9747de92db43
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Simplify make-list implementation
    
    * src/alloc.c (Fmake_list): Don’t unroll loop, as the complexity
    is not worth it these days.
---
 src/alloc.c |   36 +++---------------------------------
 1 file changed, 3 insertions(+), 33 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 1a6d4e2..f7da7e4 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2872,44 +2872,14 @@ usage: (list &rest OBJECTS)  */)
 
 DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
        doc: /* Return a newly created list of length LENGTH, with each element 
being INIT.  */)
-  (register Lisp_Object length, Lisp_Object init)
+  (Lisp_Object length, Lisp_Object init)
 {
-  register Lisp_Object val;
-  register EMACS_INT size;
-
+  Lisp_Object val = Qnil;
   CHECK_NATNUM (length);
-  size = XFASTINT (length);
 
-  val = Qnil;
-  while (size > 0)
+  for (EMACS_INT size = XFASTINT (length); 0 < size; size--)
     {
       val = Fcons (init, val);
-      --size;
-
-      if (size > 0)
-       {
-         val = Fcons (init, val);
-         --size;
-
-         if (size > 0)
-           {
-             val = Fcons (init, val);
-             --size;
-
-             if (size > 0)
-               {
-                 val = Fcons (init, val);
-                 --size;
-
-                 if (size > 0)
-                   {
-                     val = Fcons (init, val);
-                     --size;
-                   }
-               }
-           }
-       }
-
       QUIT;
     }
 



reply via email to

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