From 157086e750187f6bceeea697d10bf58403c7d5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Fri, 4 Dec 2020 14:44:57 +0100 Subject: Split RichString_(append|appendn|write) into wide and ascii RichString_writeFrom takes a top spot during performance analysis due to the calls to mbstowcs() and iswprint(). Most of the time we know in advance that we are only going to print regular ASCII characters. --- LoadAverageMeter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'LoadAverageMeter.c') diff --git a/LoadAverageMeter.c b/LoadAverageMeter.c index d5424cd2..248d65cd 100644 --- a/LoadAverageMeter.c +++ b/LoadAverageMeter.c @@ -33,11 +33,11 @@ static void LoadAverageMeter_display(const Object* cast, RichString* out) { const Meter* this = (const Meter*)cast; char buffer[20]; xSnprintf(buffer, sizeof(buffer), "%.2f ", this->values[0]); - RichString_write(out, CRT_colors[LOAD_AVERAGE_ONE], buffer); + RichString_writeAscii(out, CRT_colors[LOAD_AVERAGE_ONE], buffer); xSnprintf(buffer, sizeof(buffer), "%.2f ", this->values[1]); - RichString_append(out, CRT_colors[LOAD_AVERAGE_FIVE], buffer); + RichString_appendAscii(out, CRT_colors[LOAD_AVERAGE_FIVE], buffer); xSnprintf(buffer, sizeof(buffer), "%.2f ", this->values[2]); - RichString_append(out, CRT_colors[LOAD_AVERAGE_FIFTEEN], buffer); + RichString_appendAscii(out, CRT_colors[LOAD_AVERAGE_FIFTEEN], buffer); } static void LoadMeter_updateValues(Meter* this, char* buffer, size_t size) { @@ -53,7 +53,7 @@ static void LoadMeter_display(const Object* cast, RichString* out) { const Meter* this = (const Meter*)cast; char buffer[20]; xSnprintf(buffer, sizeof(buffer), "%.2f ", this->values[0]); - RichString_write(out, CRT_colors[LOAD], buffer); + RichString_writeAscii(out, CRT_colors[LOAD], buffer); } const MeterClass LoadAverageMeter_class = { -- cgit v1.2.3