changeset 37930:ee47b5c14208

(Fsingle_key_description): Create a multibyte string only if necessary.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 28 May 2001 16:21:10 +0000
parents ca726d19c1be
children 85e6863c11b7
files src/keymap.c
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/keymap.c	Mon May 28 16:20:48 2001 +0000
+++ b/src/keymap.c	Mon May 28 16:21:10 2001 +0000
@@ -1959,14 +1959,18 @@
 	}
       else
 	{
-	  char tem[KEY_DESCRIPTION_SIZE];
-	  int len;
-
-	  *push_key_description (XUINT (key), tem, 1) = 0;
-	  len = strlen (tem);
-	  return make_multibyte_string (tem,
-					multibyte_chars_in_text (tem, len),
-					len);
+	  char tem[KEY_DESCRIPTION_SIZE], *end;
+	  int nbytes, nchars;
+	  Lisp_Object string;
+
+	  end = push_key_description (XUINT (key), tem, 1);
+	  nbytes = end - tem;
+	  nchars = multibyte_chars_in_text (tem, nbytes);
+	  if (nchars == nbytes)
+	    string = build_string (tem);
+	  else
+	    string = make_multibyte_string (tem, nchars, nbytes);
+	  return string;
 	}
     }
   else if (SYMBOLP (key))	/* Function key or event-symbol */