Commit f0559026 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Code cleanup in xdisp.c regarding string_char_and_length.

 xdisp.c (string_pos_nchars_ahead, c_string_pos)
 (face_before_or_after_it_pos, next_element_from_string)
 (next_element_from_c_string, produce_stretch_glyph): Remove unused
 calculations of maximum string length before calling
 string_char_and_length and STRING_CHAR_AND_LENGTH.
 (string_char_and_length): Update commentary: MAXLEN is no longer
 needed.
parent 3c73e30e
2010-12-11 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (string_pos_nchars_ahead, c_string_pos)
(face_before_or_after_it_pos, next_element_from_string)
(next_element_from_c_string, produce_stretch_glyph): Remove unused
calculations of maximum string length before calling
string_char_and_length and STRING_CHAR_AND_LENGTH.
(string_char_and_length): Update commentary: MAXLEN is no longer
needed.
2010-12-10 Jan Djärv <jan.h.d@swipnet.se> 2010-12-10 Jan Djärv <jan.h.d@swipnet.se>
   
* keyboard.c (kbd_buffer_get_event): Construct SAVE_SESSION_EVENT * keyboard.c (kbd_buffer_get_event): Construct SAVE_SESSION_EVENT
......
...@@ -1454,11 +1454,10 @@ pos_visible_p (w, charpos, x, y, rtop, rbot, rowh, vpos) ...@@ -1454,11 +1454,10 @@ pos_visible_p (w, charpos, x, y, rtop, rbot, rowh, vpos)
} }
   
   
/* Return the next character from STR which is MAXLEN bytes long. /* Return the next character from STR. Return in *LEN the length of
Return in *LEN the length of the character. This is like the character. This is like STRING_CHAR_AND_LENGTH but never
STRING_CHAR_AND_LENGTH but never returns an invalid character. If returns an invalid character. If we find one, we return a `?', but
we find one, we return a `?', but with the length of the invalid with the length of the invalid character. */
character. */
   
static INLINE int static INLINE int
string_char_and_length (str, len) string_char_and_length (str, len)
...@@ -1492,15 +1491,13 @@ string_pos_nchars_ahead (pos, string, nchars) ...@@ -1492,15 +1491,13 @@ string_pos_nchars_ahead (pos, string, nchars)
   
if (STRING_MULTIBYTE (string)) if (STRING_MULTIBYTE (string))
{ {
int rest = SBYTES (string) - BYTEPOS (pos);
const unsigned char *p = SDATA (string) + BYTEPOS (pos); const unsigned char *p = SDATA (string) + BYTEPOS (pos);
int len; int len;
   
while (nchars--) while (nchars--)
{ {
string_char_and_length (p, &len); string_char_and_length (p, &len);
p += len, rest -= len; p += len;
xassert (rest >= 0);
CHARPOS (pos) += 1; CHARPOS (pos) += 1;
BYTEPOS (pos) += len; BYTEPOS (pos) += len;
} }
...@@ -1545,14 +1542,13 @@ c_string_pos (charpos, s, multibyte_p) ...@@ -1545,14 +1542,13 @@ c_string_pos (charpos, s, multibyte_p)
   
if (multibyte_p) if (multibyte_p)
{ {
int rest = strlen (s), len; int len;
   
SET_TEXT_POS (pos, 0, 0); SET_TEXT_POS (pos, 0, 0);
while (charpos--) while (charpos--)
{ {
string_char_and_length (s, &len); string_char_and_length (s, &len);
s += len, rest -= len; s += len;
xassert (rest >= 0);
CHARPOS (pos) += 1; CHARPOS (pos) += 1;
BYTEPOS (pos) += len; BYTEPOS (pos) += len;
} }
...@@ -3614,7 +3610,6 @@ face_before_or_after_it_pos (it, before_p) ...@@ -3614,7 +3610,6 @@ face_before_or_after_it_pos (it, before_p)
if (STRING_MULTIBYTE (it->string)) if (STRING_MULTIBYTE (it->string))
{ {
const unsigned char *p = SDATA (it->string) + BYTEPOS (pos); const unsigned char *p = SDATA (it->string) + BYTEPOS (pos);
int rest = SBYTES (it->string) - BYTEPOS (pos);
int c, len; int c, len;
struct face *face = FACE_FROM_ID (it->f, face_id); struct face *face = FACE_FROM_ID (it->f, face_id);
   
...@@ -6264,7 +6259,6 @@ next_element_from_string (it) ...@@ -6264,7 +6259,6 @@ next_element_from_string (it)
} }
else if (STRING_MULTIBYTE (it->string)) else if (STRING_MULTIBYTE (it->string))
{ {
int remaining = SBYTES (it->string) - IT_STRING_BYTEPOS (*it);
const unsigned char *s = (SDATA (it->string) const unsigned char *s = (SDATA (it->string)
+ IT_STRING_BYTEPOS (*it)); + IT_STRING_BYTEPOS (*it));
it->c = string_char_and_length (s, &it->len); it->c = string_char_and_length (s, &it->len);
...@@ -6300,7 +6294,6 @@ next_element_from_string (it) ...@@ -6300,7 +6294,6 @@ next_element_from_string (it)
} }
else if (STRING_MULTIBYTE (it->string)) else if (STRING_MULTIBYTE (it->string))
{ {
int maxlen = SBYTES (it->string) - IT_STRING_BYTEPOS (*it);
const unsigned char *s = (SDATA (it->string) const unsigned char *s = (SDATA (it->string)
+ IT_STRING_BYTEPOS (*it)); + IT_STRING_BYTEPOS (*it));
it->c = string_char_and_length (s, &it->len); it->c = string_char_and_length (s, &it->len);
...@@ -6354,13 +6347,7 @@ next_element_from_c_string (it) ...@@ -6354,13 +6347,7 @@ next_element_from_c_string (it)
BYTEPOS (it->position) = CHARPOS (it->position) = -1; BYTEPOS (it->position) = CHARPOS (it->position) = -1;
} }
else if (it->multibyte_p) else if (it->multibyte_p)
{ it->c = string_char_and_length (it->s + IT_BYTEPOS (*it), &it->len);
/* Implementation note: The calls to strlen apparently aren't a
performance problem because there is no noticeable performance
difference between Emacs running in unibyte or multibyte mode. */
int maxlen = strlen (it->s) - IT_BYTEPOS (*it);
it->c = string_char_and_length (it->s + IT_BYTEPOS (*it), &it->len);
}
else else
it->c = it->s[IT_BYTEPOS (*it)], it->len = 1; it->c = it->s[IT_BYTEPOS (*it)], it->len = 1;
   
...@@ -20917,11 +20904,7 @@ produce_stretch_glyph (it) ...@@ -20917,11 +20904,7 @@ produce_stretch_glyph (it)
   
it2 = *it; it2 = *it;
if (it->multibyte_p) if (it->multibyte_p)
{ it2.c = it2.char_to_display = STRING_CHAR_AND_LENGTH (p, it2.len);
int maxlen = ((IT_BYTEPOS (*it) >= GPT ? ZV : GPT)
- IT_BYTEPOS (*it));
it2.c = it2.char_to_display = STRING_CHAR_AND_LENGTH (p, it2.len);
}
else else
{ {
it2.c = it2.char_to_display = *p, it2.len = 1; it2.c = it2.char_to_display = *p, it2.len = 1;
......
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