From c1f134b59b870f6385364a611911a1344cfef7a2 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 12 Jun 2011 19:41:13 -0700 Subject: [PATCH] * fns.c (concat): Minor tuning based on overflow analysis. This doesn't fix any bugs. Use int to hold character, instead of constantly refetching from Emacs object. Use XFASTINT, not XINT, for value known to be a character. Don't bother comparing a single byte to 0400, as it's always less. --- src/ChangeLog | 6 ++++++ src/fns.c | 32 ++++++++++++++------------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 08b99fd1b79..f5b81cff88e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2011-06-13 Paul Eggert + * fns.c (concat): Minor tuning based on overflow analysis. + This doesn't fix any bugs. Use int to hold character, instead + of constantly refetching from Emacs object. Use XFASTINT, not + XINT, for value known to be a character. Don't bother comparing + a single byte to 0400, as it's always less. + * floatfns.c (Fexpt): * fileio.c (make_temp_name): Omit unnecessary cast to unsigned. diff --git a/src/fns.c b/src/fns.c index 250df728cab..b42e5f3b7c2 100644 --- a/src/fns.c +++ b/src/fns.c @@ -504,6 +504,7 @@ concat (size_t nargs, Lisp_Object *args, as well as the number of characters. */ EMACS_INT i; Lisp_Object ch; + int c; EMACS_INT this_len_byte; if (VECTORP (this) || COMPILEDP (this)) @@ -511,9 +512,10 @@ concat (size_t nargs, Lisp_Object *args, { ch = AREF (this, i); CHECK_CHARACTER (ch); - this_len_byte = CHAR_BYTES (XINT (ch)); + c = XFASTINT (ch); + this_len_byte = CHAR_BYTES (c); result_len_byte += this_len_byte; - if (! ASCII_CHAR_P (XINT (ch)) && ! CHAR_BYTE8_P (XINT (ch))) + if (! ASCII_CHAR_P (c) && ! CHAR_BYTE8_P (c)) some_multibyte = 1; } else if (BOOL_VECTOR_P (this) && XBOOL_VECTOR (this)->size > 0) @@ -523,9 +525,10 @@ concat (size_t nargs, Lisp_Object *args, { ch = XCAR (this); CHECK_CHARACTER (ch); - this_len_byte = CHAR_BYTES (XINT (ch)); + c = XFASTINT (ch); + this_len_byte = CHAR_BYTES (c); result_len_byte += this_len_byte; - if (! ASCII_CHAR_P (XINT (ch)) && ! CHAR_BYTE8_P (XINT (ch))) + if (! ASCII_CHAR_P (c) && ! CHAR_BYTE8_P (c)) some_multibyte = 1; } else if (STRINGP (this)) @@ -631,23 +634,16 @@ concat (size_t nargs, Lisp_Object *args, { int c; if (STRING_MULTIBYTE (this)) - { - FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, this, - thisindex, - thisindex_byte); - XSETFASTINT (elt, c); - } + FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, this, + thisindex, + thisindex_byte); else { - XSETFASTINT (elt, SREF (this, thisindex)); thisindex++; - if (some_multibyte - && !ASCII_CHAR_P (XINT (elt)) - && XINT (elt) < 0400) - { - c = BYTE8_TO_CHAR (XINT (elt)); - XSETINT (elt, c); - } + c = SREF (this, thisindex); thisindex++; + if (some_multibyte && !ASCII_CHAR_P (c)) + c = BYTE8_TO_CHAR (c); } + XSETFASTINT (elt, c); } else if (BOOL_VECTOR_P (this)) { -- 2.39.2