mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-14 13:04:35 +03:00
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.
This commit is contained in:

committed by
cgzones

parent
099dab88be
commit
436808ff99
@ -97,10 +97,11 @@ static void DiskIOMeter_display(ATTR_UNUSED const Object* cast, RichString* out)
|
||||
}
|
||||
|
||||
char buffer[16];
|
||||
int len;
|
||||
|
||||
int color = cached_utilisation_diff > 40.0 ? METER_VALUE_NOTICE : METER_VALUE;
|
||||
xSnprintf(buffer, sizeof(buffer), "%.1f%%", cached_utilisation_diff);
|
||||
RichString_writeAscii(out, CRT_colors[color], buffer);
|
||||
len = xSnprintf(buffer, sizeof(buffer), "%.1f%%", cached_utilisation_diff);
|
||||
RichString_appendnAscii(out, CRT_colors[color], buffer, len);
|
||||
|
||||
RichString_appendAscii(out, CRT_colors[METER_TEXT], " read: ");
|
||||
Meter_humanUnit(buffer, cached_read_diff, sizeof(buffer));
|
||||
|
Reference in New Issue
Block a user