From 08408b13faa911b586ac0c181159ada452a942cc Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 26 Apr 2020 19:30:37 -0700 Subject: [PATCH] Simplify string-to-char MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * src/editfns.c (Fstring_to_char): Simplify. * src/editfns.c (Fstring_to_char): Simplify. This tweak improved the CPU time performance of ‘make compile-always’ by about 1.8% on my platform. --- src/editfns.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/editfns.c b/src/editfns.c index 1a199bad6de..c32488e271f 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -162,20 +162,14 @@ DEFUN ("byte-to-string", Fbyte_to_string, Sbyte_to_string, 1, 1, 0, DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0, doc: /* Return the first character in STRING. */) - (register Lisp_Object string) + (Lisp_Object string) { - register Lisp_Object val; CHECK_STRING (string); - if (SCHARS (string)) - { - if (STRING_MULTIBYTE (string)) - XSETFASTINT (val, STRING_CHAR (SDATA (string))); - else - XSETFASTINT (val, SREF (string, 0)); - } - else - XSETFASTINT (val, 0); - return val; + + /* This returns zero if STRING is empty. */ + return make_fixnum (STRING_MULTIBYTE (string) + ? STRING_CHAR (SDATA (string)) + : SREF (string, 0)); } DEFUN ("point", Fpoint, Spoint, 0, 0, 0, -- 2.39.2