From 436808ff99d7b7e6f5d6e8f3127d9d03f6295f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Wed, 14 Apr 2021 20:47:42 +0200 Subject: 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. --- OptionItem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OptionItem.c') diff --git a/OptionItem.c b/OptionItem.c index 688fab8f..437f7ead 100644 --- a/OptionItem.c +++ b/OptionItem.c @@ -53,7 +53,7 @@ static void NumberItem_display(const Object* cast, RichString* out) { } else { written = xSnprintf(buffer, sizeof(buffer), "%d", NumberItem_get(this)); } - RichString_appendAscii(out, CRT_colors[CHECK_MARK], buffer); + RichString_appendnAscii(out, CRT_colors[CHECK_MARK], buffer, written); RichString_appendAscii(out, CRT_colors[CHECK_BOX], "]"); for (int i = written; i < 5; i++) { RichString_appendAscii(out, CRT_colors[CHECK_BOX], " "); -- cgit v1.2.3