diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-12-04 14:44:57 +0100 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2020-12-08 20:58:40 +0100 |
commit | 157086e750187f6bceeea697d10bf58403c7d5de (patch) | |
tree | 82c6512c1a1e88c9ab9f77ca9bf1531da265e331 /linux | |
parent | 5506925b346b09f8556ce2c8f83fe3d69dc1c03c (diff) |
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.
Diffstat (limited to 'linux')
-rw-r--r-- | linux/LinuxProcess.c | 6 | ||||
-rw-r--r-- | linux/PressureStallMeter.c | 6 | ||||
-rw-r--r-- | linux/SystemdMeter.c | 20 | ||||
-rw-r--r-- | linux/ZramMeter.c | 14 |
4 files changed, 24 insertions, 22 deletions
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index 8298000a..05626065 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -536,7 +536,7 @@ static void LinuxProcess_writeCommand(const Process* this, int attr, int baseAtt if(lp->procExeDeleted) baseAttr = CRT_colors[FAILED_READ]; - RichString_append(str, attr, lp->mergedCommand.str); + RichString_appendWide(str, attr, lp->mergedCommand.str); if (lp->mergedCommand.commEnd) { if (!lp->mergedCommand.separateComm && commStart == baseStart && highlightBaseName) { @@ -608,7 +608,7 @@ static void LinuxProcess_writeCommandField(const Process *this, RichString *str, n -= (buf - buffer); const char* draw = CRT_treeStr[lastItem ? (this->settings->direction == 1 ? TREE_STR_BEND : TREE_STR_TEND) : TREE_STR_RTEE]; xSnprintf(buf, n, "%s%s ", draw, this->showChildren ? CRT_treeStr[TREE_STR_SHUT] : CRT_treeStr[TREE_STR_OPEN] ); - RichString_append(str, CRT_colors[PROCESS_TREE], buffer); + RichString_appendWide(str, CRT_colors[PROCESS_TREE], buffer); LinuxProcess_writeCommand(this, attr, baseattr, str); } } @@ -757,7 +757,7 @@ static void LinuxProcess_writeField(const Process* this, RichString* str, Proces Process_writeField(this, str, field); return; } - RichString_append(str, attr, buffer); + RichString_appendWide(str, attr, buffer); } static long LinuxProcess_compare(const void* v1, const void* v2) { diff --git a/linux/PressureStallMeter.c b/linux/PressureStallMeter.c index 745068c9..91ac562b 100644 --- a/linux/PressureStallMeter.c +++ b/linux/PressureStallMeter.c @@ -50,11 +50,11 @@ static void PressureStallMeter_display(const Object* cast, RichString* out) { const Meter* this = (const Meter*)cast; char buffer[20]; xSnprintf(buffer, sizeof(buffer), "%.2lf%% ", this->values[0]); - RichString_write(out, CRT_colors[PRESSURE_STALL_TEN], buffer); + RichString_writeAscii(out, CRT_colors[PRESSURE_STALL_TEN], buffer); xSnprintf(buffer, sizeof(buffer), "%.2lf%% ", this->values[1]); - RichString_append(out, CRT_colors[PRESSURE_STALL_SIXTY], buffer); + RichString_appendAscii(out, CRT_colors[PRESSURE_STALL_SIXTY], buffer); xSnprintf(buffer, sizeof(buffer), "%.2lf%% ", this->values[2]); - RichString_append(out, CRT_colors[PRESSURE_STALL_THREEHUNDRED], buffer); + RichString_appendAscii(out, CRT_colors[PRESSURE_STALL_THREEHUNDRED], buffer); } const MeterClass PressureStallCPUSomeMeter_class = { diff --git a/linux/SystemdMeter.c b/linux/SystemdMeter.c index 4350d264..61bb59b3 100644 --- a/linux/SystemdMeter.c +++ b/linux/SystemdMeter.c @@ -267,9 +267,9 @@ static void SystemdMeter_display(ATTR_UNUSED const Object* cast, RichString* out char buffer[16]; int color = (systemState && 0 == strcmp(systemState, "running")) ? METER_VALUE_OK : METER_VALUE_ERROR; - RichString_write(out, CRT_colors[color], systemState ? systemState : "???"); + RichString_writeAscii(out, CRT_colors[color], systemState ? systemState : "N/A"); - RichString_append(out, CRT_colors[METER_TEXT], " ("); + RichString_appendAscii(out, CRT_colors[METER_TEXT], " ("); if (nFailedUnits == INVALID_VALUE) { buffer[0] = '?'; @@ -277,9 +277,9 @@ static void SystemdMeter_display(ATTR_UNUSED const Object* cast, RichString* out } else { xSnprintf(buffer, sizeof(buffer), "%u", nFailedUnits); } - RichString_append(out, zeroDigitColor(nFailedUnits), buffer); + RichString_appendAscii(out, zeroDigitColor(nFailedUnits), buffer); - RichString_append(out, CRT_colors[METER_TEXT], "/"); + RichString_appendAscii(out, CRT_colors[METER_TEXT], "/"); if (nNames == INVALID_VALUE) { buffer[0] = '?'; @@ -287,9 +287,9 @@ static void SystemdMeter_display(ATTR_UNUSED const Object* cast, RichString* out } else { xSnprintf(buffer, sizeof(buffer), "%u", nNames); } - RichString_append(out, valueDigitColor(nNames), buffer); + RichString_appendAscii(out, valueDigitColor(nNames), buffer); - RichString_append(out, CRT_colors[METER_TEXT], " failed) ("); + RichString_appendAscii(out, CRT_colors[METER_TEXT], " failed) ("); if (nJobs == INVALID_VALUE) { buffer[0] = '?'; @@ -297,9 +297,9 @@ static void SystemdMeter_display(ATTR_UNUSED const Object* cast, RichString* out } else { xSnprintf(buffer, sizeof(buffer), "%u", nJobs); } - RichString_append(out, zeroDigitColor(nJobs), buffer); + RichString_appendAscii(out, zeroDigitColor(nJobs), buffer); - RichString_append(out, CRT_colors[METER_TEXT], "/"); + RichString_appendAscii(out, CRT_colors[METER_TEXT], "/"); if (nInstalledJobs == INVALID_VALUE) { buffer[0] = '?'; @@ -307,9 +307,9 @@ static void SystemdMeter_display(ATTR_UNUSED const Object* cast, RichString* out } else { xSnprintf(buffer, sizeof(buffer), "%u", nInstalledJobs); } - RichString_append(out, valueDigitColor(nInstalledJobs), buffer); + RichString_appendAscii(out, valueDigitColor(nInstalledJobs), buffer); - RichString_append(out, CRT_colors[METER_TEXT], " jobs)"); + RichString_appendAscii(out, CRT_colors[METER_TEXT], " jobs)"); } static const int SystemdMeter_attributes[] = { diff --git a/linux/ZramMeter.c b/linux/ZramMeter.c index e6b6937e..723de0ac 100644 --- a/linux/ZramMeter.c +++ b/linux/ZramMeter.c @@ -37,17 +37,19 @@ static void ZramMeter_updateValues(Meter* this, char* buffer, size_t size) { static void ZramMeter_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_appendAscii(out, CRT_colors[METER_VALUE], buffer); - RichString_append(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); Meter_humanUnit(buffer, this->values[1], sizeof(buffer)); - RichString_append(out, CRT_colors[METER_TEXT], " uncompressed:"); - RichString_append(out, CRT_colors[METER_VALUE], buffer); + RichString_appendAscii(out, CRT_colors[METER_TEXT], " uncompressed:"); + RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); } const MeterClass ZramMeter_class = { |