summaryrefslogtreecommitdiffstats
path: root/linux/PressureStallMeter.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-04-14 20:47:42 +0200
committercgzones <cgzones@googlemail.com>2021-04-26 17:51:45 +0200
commit436808ff99d7b7e6f5d6e8f3127d9d03f6295f98 (patch)
tree46610957022066f7da0170c1edcc5991435d5400 /linux/PressureStallMeter.c
parent099dab88be5a7a1c9207e7bc7116618b7108f851 (diff)
Use RichString_appendnAscii where possible
`RichString_appendnAscii()` avoids a `strlen(3)` call over ` RichString_appendAscii()`. Use the former where the length is available from a previous checked `snprintf(3)` call. Keep `RichString_appendAscii()` when passing a string literal and rely on compilers to optimize the `strlen(3)` call away.
Diffstat (limited to 'linux/PressureStallMeter.c')
-rw-r--r--linux/PressureStallMeter.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/linux/PressureStallMeter.c b/linux/PressureStallMeter.c
index 238df7e4..573c1a3a 100644
--- a/linux/PressureStallMeter.c
+++ b/linux/PressureStallMeter.c
@@ -53,12 +53,14 @@ static void PressureStallMeter_updateValues(Meter* this) {
static void PressureStallMeter_display(const Object* cast, RichString* out) {
const Meter* this = (const Meter*)cast;
char buffer[20];
- xSnprintf(buffer, sizeof(buffer), "%5.2lf%% ", this->values[0]);
- RichString_writeAscii(out, CRT_colors[PRESSURE_STALL_TEN], buffer);
- xSnprintf(buffer, sizeof(buffer), "%5.2lf%% ", this->values[1]);
- RichString_appendAscii(out, CRT_colors[PRESSURE_STALL_SIXTY], buffer);
- xSnprintf(buffer, sizeof(buffer), "%5.2lf%% ", this->values[2]);
- RichString_appendAscii(out, CRT_colors[PRESSURE_STALL_THREEHUNDRED], buffer);
+ int len;
+
+ len = xSnprintf(buffer, sizeof(buffer), "%5.2lf%% ", this->values[0]);
+ RichString_appendnAscii(out, CRT_colors[PRESSURE_STALL_TEN], buffer, len);
+ len = xSnprintf(buffer, sizeof(buffer), "%5.2lf%% ", this->values[1]);
+ RichString_appendnAscii(out, CRT_colors[PRESSURE_STALL_SIXTY], buffer, len);
+ len = xSnprintf(buffer, sizeof(buffer), "%5.2lf%% ", this->values[2]);
+ RichString_appendnAscii(out, CRT_colors[PRESSURE_STALL_THREEHUNDRED], buffer, len);
}
const MeterClass PressureStallCPUSomeMeter_class = {

© 2014-2024 Faster IT GmbH | imprint | privacy policy