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. --- SwapMeter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'SwapMeter.c') diff --git a/SwapMeter.c b/SwapMeter.c index fcc11c54..e39cfd9f 100644 --- a/SwapMeter.c +++ b/SwapMeter.c @@ -32,12 +32,12 @@ static void SwapMeter_updateValues(Meter* this, char* buffer, size_t size) { static void SwapMeter_display(const Object* cast, RichString* out) { char buffer[50]; const Meter* this = (const Meter*)cast; - RichString_write(out, CRT_colors[METER_TEXT], ":"); + RichString_writeAscii(out, CRT_colors[METER_TEXT], ":"); Meter_humanUnit(buffer, this->total, sizeof(buffer)); - RichString_append(out, CRT_colors[METER_VALUE], buffer); + RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); Meter_humanUnit(buffer, this->values[0], sizeof(buffer)); - RichString_append(out, CRT_colors[METER_TEXT], " used:"); - RichString_append(out, CRT_colors[METER_VALUE], buffer); + RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:"); + RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); } const MeterClass SwapMeter_class = { -- cgit v1.2.3