diff options
| author | Paul Eggert | 2017-01-25 19:07:57 -0800 |
|---|---|---|
| committer | Paul Eggert | 2017-01-25 21:25:36 -0800 |
| commit | 0dfd9a69186e12e53b8aa759c47b9747de92db43 (patch) | |
| tree | 9d2929ce8ce7f8bbb92df9b02d572aaa928cda5b /src/alloc.c | |
| parent | 44765de2005fb56c5930383d6bd1e959a0102a45 (diff) | |
| download | emacs-0dfd9a69186e12e53b8aa759c47b9747de92db43.tar.gz emacs-0dfd9a69186e12e53b8aa759c47b9747de92db43.zip | |
Simplify make-list implementation
* src/alloc.c (Fmake_list): Don’t unroll loop, as the complexity
is not worth it these days.
Diffstat (limited to 'src/alloc.c')
| -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) */) | |||
| 2872 | 2872 | ||
| 2873 | DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, | 2873 | DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, |
| 2874 | doc: /* Return a newly created list of length LENGTH, with each element being INIT. */) | 2874 | doc: /* Return a newly created list of length LENGTH, with each element being INIT. */) |
| 2875 | (register Lisp_Object length, Lisp_Object init) | 2875 | (Lisp_Object length, Lisp_Object init) |
| 2876 | { | 2876 | { |
| 2877 | register Lisp_Object val; | 2877 | Lisp_Object val = Qnil; |
| 2878 | register EMACS_INT size; | ||
| 2879 | |||
| 2880 | CHECK_NATNUM (length); | 2878 | CHECK_NATNUM (length); |
| 2881 | size = XFASTINT (length); | ||
| 2882 | 2879 | ||
| 2883 | val = Qnil; | 2880 | for (EMACS_INT size = XFASTINT (length); 0 < size; size--) |
| 2884 | while (size > 0) | ||
| 2885 | { | 2881 | { |
| 2886 | val = Fcons (init, val); | 2882 | val = Fcons (init, val); |
| 2887 | --size; | ||
| 2888 | |||
| 2889 | if (size > 0) | ||
| 2890 | { | ||
| 2891 | val = Fcons (init, val); | ||
| 2892 | --size; | ||
| 2893 | |||
| 2894 | if (size > 0) | ||
| 2895 | { | ||
| 2896 | val = Fcons (init, val); | ||
| 2897 | --size; | ||
| 2898 | |||
| 2899 | if (size > 0) | ||
| 2900 | { | ||
| 2901 | val = Fcons (init, val); | ||
| 2902 | --size; | ||
| 2903 | |||
| 2904 | if (size > 0) | ||
| 2905 | { | ||
| 2906 | val = Fcons (init, val); | ||
| 2907 | --size; | ||
| 2908 | } | ||
| 2909 | } | ||
| 2910 | } | ||
| 2911 | } | ||
| 2912 | |||
| 2913 | QUIT; | 2883 | QUIT; |
| 2914 | } | 2884 | } |
| 2915 | 2885 | ||