diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-01-25 19:07:57 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-01-25 21:25:36 -0800 |
commit | 0dfd9a69186e12e53b8aa759c47b9747de92db43 (patch) | |
tree | 9d2929ce8ce7f8bbb92df9b02d572aaa928cda5b | |
parent | 44765de2005fb56c5930383d6bd1e959a0102a45 (diff) | |
download | emacs-0dfd9a69186e12e53b8aa759c47b9747de92db43.tar.gz |
Simplify make-list implementation
* src/alloc.c (Fmake_list): Don’t unroll loop, as the complexity
is not worth it these days.
-rw-r--r-- | src/alloc.c | 36 |
1 files changed, 3 insertions, 33 deletions
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; } |