mirror of git://git.sv.gnu.org/nano.git
tweaks: simplify two fragments of code
This makes the handling of plain ASCII a tiny bit slower, but it affects only the users of --constantshow without --minibar, so... All other uses of mbstrlen() and collect_char() are not in speed- critical code paths.
This commit is contained in:
parent
eb7181b35e
commit
48fa14acc0
18
src/chars.c
18
src/chars.c
|
@ -297,13 +297,7 @@ size_t mbstrlen(const char *pointer)
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
while (*pointer != '\0') {
|
while (*pointer != '\0') {
|
||||||
#ifdef ENABLE_UTF8
|
pointer += char_length(pointer);
|
||||||
if ((unsigned char)*pointer > 0xC1)
|
|
||||||
pointer += char_length(pointer);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
pointer++;
|
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,15 +308,7 @@ size_t mbstrlen(const char *pointer)
|
||||||
* given string, and return a copy of this character in *thechar. */
|
* given string, and return a copy of this character in *thechar. */
|
||||||
int collect_char(const char *string, char *thechar)
|
int collect_char(const char *string, char *thechar)
|
||||||
{
|
{
|
||||||
int charlen;
|
int charlen = char_length(string);
|
||||||
|
|
||||||
#ifdef ENABLE_UTF8
|
|
||||||
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
|
|
||||||
if ((unsigned char)*string > 0xC1)
|
|
||||||
charlen = char_length(string);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
charlen = 1;
|
|
||||||
|
|
||||||
for (int i = 0; i < charlen; i++)
|
for (int i = 0; i < charlen; i++)
|
||||||
thechar[i] = string[i];
|
thechar[i] = string[i];
|
||||||
|
|
Loading…
Reference in New Issue