From: Paul Eggert Date: Mon, 27 Apr 2020 02:30:37 +0000 (-0700) Subject: Simplify string-to-char X-Git-Tag: emacs-28.0.90~7501 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=08408b13faa911b586ac0c181159ada452a942cc;p=emacs.git Simplify string-to-char * 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. --- 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,