From: Paul Eggert Date: Thu, 26 Jan 2017 03:07:57 +0000 (-0800) Subject: Simplify make-list implementation X-Git-Tag: emacs-26.0.90~870^2~49 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0dfd9a69186e12e53b8aa759c47b9747de92db43;p=emacs.git Simplify make-list implementation * src/alloc.c (Fmake_list): Don’t unroll loop, as the complexity is not worth it these days. --- diff --git a/src/alloc.c b/src/alloc.c index 1a6d4e2d565..f7da7e44f29 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; }