Commit 0dfd9a69 authored by Paul Eggert's avatar Paul Eggert
Browse files

Simplify make-list implementation

* src/alloc.c (Fmake_list): Don’t unroll loop, as the complexity
is not worth it these days.
parent 44765de2
...@@ -2872,44 +2872,14 @@ usage: (list &rest OBJECTS) */) ...@@ -2872,44 +2872,14 @@ usage: (list &rest OBJECTS) */)
DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
doc: /* Return a newly created list of length LENGTH, with each element being INIT. */) 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; Lisp_Object val = Qnil;
register EMACS_INT size;
CHECK_NATNUM (length); CHECK_NATNUM (length);
size = XFASTINT (length);
val = Qnil; for (EMACS_INT size = XFASTINT (length); 0 < size; size--)
while (size > 0)
{ {
val = Fcons (init, val); 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; QUIT;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment