commit 48fa14acc0b64aa5c05eda9a886cd91fdf3d08cc
parent eb7181b35ec98cd847aee895218e40462e5d06a5
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 13 Apr 2021 11:14:45 +0200
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.
Diffstat:
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/src/chars.c b/src/chars.c
@@ -297,13 +297,7 @@ size_t mbstrlen(const char *pointer)
size_t count = 0;
while (*pointer != '\0') {
-#ifdef ENABLE_UTF8
- if ((unsigned char)*pointer > 0xC1)
- pointer += char_length(pointer);
- else
-#endif
- pointer++;
-
+ pointer += char_length(pointer);
count++;
}
@@ -314,15 +308,7 @@ size_t mbstrlen(const char *pointer)
* given string, and return a copy of this character in *thechar. */
int collect_char(const char *string, char *thechar)
{
- int charlen;
-
-#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;
+ int charlen = char_length(string);
for (int i = 0; i < charlen; i++)
thechar[i] = string[i];