Commit c1f134b5 authored by Paul Eggert's avatar Paul Eggert
Browse files

* 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.
parent 395fcb93
2011-06-13 Paul Eggert <eggert@cs.ucla.edu>
* 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.
......
......@@ -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))
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment