Mercurial > emacs
diff src/keymap.c @ 7809:cf23573fa6fb
(Fkey_description): Avoid using Fmapconcat--do it directly.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 05 Jun 1994 18:30:59 +0000 |
parents | 93b5868150b9 |
children | d385199b26b6 |
line wrap: on
line diff
--- a/src/keymap.c Sun Jun 05 18:29:46 1994 +0000 +++ b/src/keymap.c Sun Jun 05 18:30:59 1994 +0000 @@ -1292,10 +1292,14 @@ (keys) Lisp_Object keys; { + int len; + int i; + Lisp_Object sep; + Lisp_Object *args; + if (XTYPE (keys) == Lisp_String) { Lisp_Object vector; - int i; vector = Fmake_vector (Flength (keys), Qnil); for (i = 0; i < XSTRING (keys)->size; i++) { @@ -1308,7 +1312,23 @@ } keys = vector; } - return Fmapconcat (Qsingle_key_description, keys, build_string (" ")); + + /* In effect, this computes + (mapconcat 'single-key-description keys " ") + but we shouldn't use mapconcat because it can do GC. */ + + len = XVECTOR (keys)->size; + sep = build_string (" "); + /* This has one extra element at the end that we don't pass to Fconcat. */ + args = (Lisp_Object *) alloca (len * 2 * sizeof (Lisp_Object)); + + for (i = 0; i < len; i++) + { + args[i * 2] = Fsingle_key_description (XVECTOR (keys)->contents[i]); + args[i * 2 + 1] = sep; + } + + return Fconcat (len * 2 - 1, args); } char *