From: Paul Eggert Date: Mon, 13 Jun 2011 02:41:13 +0000 (-0700) Subject: * fns.c (concat): Minor tuning based on overflow analysis. X-Git-Tag: emacs-pretest-24.0.90~104^2~548^2~34 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c1f134b59b870f6385364a611911a1344cfef7a2;p=emacs.git * 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. --- 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)) {