From 1d4411a474991a0910c29ba6a1b105ec08ad7b68 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 20 Feb 2020 16:38:14 +0100 Subject: [PATCH] tweaks: elide a function call, by copying a byte directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now all remaining calls of measured_copy() have a "+ 1" in their second argument, and can thus be simplified. And each of those calls is followed by terminating the string with a NUL byte, so thát can be pulled into the function. --- src/chars.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/chars.c b/src/chars.c index 06369e64..02d0cc11 100644 --- a/src/chars.c +++ b/src/chars.c @@ -204,11 +204,10 @@ int mbwidth(const char *c) * allocated) multibyte character and a length of zero. */ char *make_mbchar(long code, int *length) { - char *mb_char; + char *mb_char = charalloc(MAXCHARLEN); #ifdef ENABLE_UTF8 if (use_utf8) { - mb_char = charalloc(MAXCHARLEN); *length = wctomb(mb_char, (wchar_t)code); /* Reject invalid Unicode characters. */ @@ -219,7 +218,7 @@ char *make_mbchar(long code, int *length) } else #endif { - mb_char = measured_copy((char *)&code, 1); + *mb_char = (char)code; *length = 1; }