changeset 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 52e2eb6245d4
children 15c0bf73737e
files src/keymap.c
diffstat 1 files changed, 22 insertions(+), 2 deletions(-) [+]
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 *