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. --- NetworkIOMeter.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'NetworkIOMeter.c') diff --git a/NetworkIOMeter.c b/NetworkIOMeter.c index 90ec9909..a898b311 100644 --- a/NetworkIOMeter.c +++ b/NetworkIOMeter.c @@ -88,24 +88,24 @@ static void NetworkIOMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, s static void NetworkIOMeter_display(ATTR_UNUSED const Object* cast, RichString* out) { if (!hasData) { - RichString_write(out, CRT_colors[METER_VALUE_ERROR], "no data"); + RichString_writeAscii(out, CRT_colors[METER_VALUE_ERROR], "no data"); return; } char buffer[64]; - RichString_write(out, CRT_colors[METER_TEXT], "rx: "); + RichString_writeAscii(out, CRT_colors[METER_TEXT], "rx: "); Meter_humanUnit(buffer, cached_rxb_diff, sizeof(buffer)); - RichString_append(out, CRT_colors[METER_VALUE_IOREAD], buffer); - RichString_append(out, CRT_colors[METER_VALUE_IOREAD], "iB/s"); + RichString_appendAscii(out, CRT_colors[METER_VALUE_IOREAD], buffer); + RichString_appendAscii(out, CRT_colors[METER_VALUE_IOREAD], "iB/s"); - RichString_append(out, CRT_colors[METER_TEXT], " tx: "); + RichString_appendAscii(out, CRT_colors[METER_TEXT], " tx: "); Meter_humanUnit(buffer, cached_txb_diff, sizeof(buffer)); - RichString_append(out, CRT_colors[METER_VALUE_IOWRITE], buffer); - RichString_append(out, CRT_colors[METER_VALUE_IOWRITE], "iB/s"); + RichString_appendAscii(out, CRT_colors[METER_VALUE_IOWRITE], buffer); + RichString_appendAscii(out, CRT_colors[METER_VALUE_IOWRITE], "iB/s"); xSnprintf(buffer, sizeof(buffer), " (%lu/%lu packets) ", cached_rxp_diff, cached_txp_diff); - RichString_append(out, CRT_colors[METER_TEXT], buffer); + RichString_appendAscii(out, CRT_colors[METER_TEXT], buffer); } const MeterClass NetworkIOMeter_class = { -- cgit v1.2.3