From f4efcbde5c1a5f700a7db4cfb4e8ffe5e19bf192 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Wed, 13 Jul 2022 16:15:21 +0100 Subject: [PATCH] Remove simple use of static data from V3OutFormatter::indentSpaces --- src/V3File.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/V3File.cpp b/src/V3File.cpp index 75b2cb5d6..b19d1f868 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -623,17 +623,9 @@ V3OutFormatter::V3OutFormatter(const string& filename, V3OutFormatter::Language //---------------------------------------------------------------------- string V3OutFormatter::indentSpaces(int num) { - // Indent the specified number of spaces. Use spaces. - static char str[MAXSPACE + 20]; - char* cp = str; - if (num > MAXSPACE) num = MAXSPACE; - while (num > 0) { - *cp++ = ' '; - --num; - } - *cp++ = '\0'; - string st{str}; // No const, move optimization - return st; + // Indent the specified number of spaces. + if (num <= 0) return std::string{}; + return std::string(std::min(num, MAXSPACE), ' '); } bool V3OutFormatter::tokenMatch(const char* cp, const char* cmp) {