From f0e623c3de27a62471190387e2f692f67e5d337e Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Tue, 16 Nov 2021 13:05:02 +0100 Subject: [PATCH] Remove unnecesarry strbuf allocation --- src/common/io.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/io.c b/src/common/io.c index 0e8272fa5..90513c4e5 100644 --- a/src/common/io.c +++ b/src/common/io.c @@ -15,26 +15,26 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); ffStrbufWriteTo(&instance->config.color, stdout); - FF_STRBUF_CREATE(key); - if(customKeyFormat == NULL || customKeyFormat->length == 0) { - ffStrbufAppendS(&key, moduleName); + fputs(moduleName, stdout); if(moduleIndex > 0) - ffStrbufAppendF(&key, " %hhu", moduleIndex); + printf(" %hhu", moduleIndex); } else { + FFstrbuf key; + ffStrbufInit(&key); ffParseFormatString(&key, customKeyFormat, NULL, 1, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex} }); + ffStrbufWriteTo(&key, stdout); + ffStrbufDestroy(&key); } - ffStrbufWriteTo(&key, stdout); fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); ffStrbufWriteTo(&instance->config.separator, stdout); - ffStrbufDestroy(&key); } void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numFormatArgs, const char* message, ...)