Remove simple use of static data from V3OutFormatter::indentSpaces

This commit is contained in:
Geza Lore 2022-07-13 16:15:21 +01:00
parent 658819bb71
commit f4efcbde5c
1 changed files with 3 additions and 11 deletions

View File

@ -623,17 +623,9 @@ V3OutFormatter::V3OutFormatter(const string& filename, V3OutFormatter::Language
//---------------------------------------------------------------------- //----------------------------------------------------------------------
string V3OutFormatter::indentSpaces(int num) { string V3OutFormatter::indentSpaces(int num) {
// Indent the specified number of spaces. Use spaces. // Indent the specified number of spaces.
static char str[MAXSPACE + 20]; if (num <= 0) return std::string{};
char* cp = str; return std::string(std::min<size_t>(num, MAXSPACE), ' ');
if (num > MAXSPACE) num = MAXSPACE;
while (num > 0) {
*cp++ = ' ';
--num;
}
*cp++ = '\0';
string st{str}; // No const, move optimization
return st;
} }
bool V3OutFormatter::tokenMatch(const char* cp, const char* cmp) { bool V3OutFormatter::tokenMatch(const char* cp, const char* cmp) {