tweaks: elide a function call for the plain ASCII case
When dealing with a plain, seven-bit ASCII character, don't bother calling is_cntrl_mbchar() but determine directly whether it is a control character. Also reshuffle things so that we don't compare charlen == 1 when we already know it is 1.
Этот коммит содержится в:
родитель
8a7634f070
Коммит
3c695664ec
40
src/chars.c
40
src/chars.c
@ -314,29 +314,39 @@ int collect_char(const char *string, char *thechar)
|
|||||||
* the given string, and add this character's width to *column. */
|
* the given string, and add this character's width to *column. */
|
||||||
int advance_over(const char *string, size_t *column)
|
int advance_over(const char *string, size_t *column)
|
||||||
{
|
{
|
||||||
int charlen;
|
|
||||||
|
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
if ((signed char)*string < 0) {
|
if ((signed char)*string < 0) {
|
||||||
charlen = mblen(string, MAXCHARLEN);
|
int charlen = mblen(string, MAXCHARLEN);
|
||||||
if (charlen <= 0)
|
|
||||||
charlen = 1;
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
charlen = 1;
|
|
||||||
|
|
||||||
if (*string == '\t')
|
if (charlen > 0) {
|
||||||
*column += tabsize - *column % tabsize;
|
if (is_cntrl_mbchar(string))
|
||||||
else if (is_cntrl_mbchar(string))
|
|
||||||
*column += 2;
|
*column += 2;
|
||||||
else if (charlen == 1)
|
|
||||||
*column += 1;
|
|
||||||
#ifdef ENABLE_UTF8
|
|
||||||
else
|
else
|
||||||
*column += mbwidth(string);
|
*column += mbwidth(string);
|
||||||
#endif
|
} else {
|
||||||
|
charlen = 1;
|
||||||
|
*column += 1;
|
||||||
|
}
|
||||||
|
|
||||||
return charlen;
|
return charlen;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((unsigned char)*string < 0x20) {
|
||||||
|
if (*string == '\t')
|
||||||
|
*column += tabsize - *column % tabsize;
|
||||||
|
else
|
||||||
|
*column += 2;
|
||||||
|
} else if (*string == 0x7F)
|
||||||
|
*column += 2;
|
||||||
|
#ifndef ENABLE_UTF8
|
||||||
|
else if (0x7F < (unsigned char)*string && (unsigned char)*string < 0xA0)
|
||||||
|
*column += 2;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
*column += 1;
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the index in buf of the beginning of the multibyte character
|
/* Return the index in buf of the beginning of the multibyte character
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user