From: Gabe Black Date: Wed, 14 Oct 2020 08:21:41 +0000 (-0700) Subject: base: Clean up some #ifs in _format_string. X-Git-Tag: develop-gem5-snapshot~617 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=edf8b34026c564e28ac715af8bc8088ed9c6e94f;p=gem5.git base: Clean up some #ifs in _format_string. These were checking for gcc version 3, well below the minimum version we support, and were hard wired to be enabled anyway. This change gets rid of the check and the dead code on the hard wired off branch. Also, this change cleans up the style in the surviving code and simplifies it slightly. Change-Id: I8df73a378f478413c111a4dea962450a37fb4092 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35977 Reviewed-by: Daniel Carvalho Maintainer: Gabe Black Tested-by: kokoro --- diff --git a/src/base/cprintf_formats.hh b/src/base/cprintf_formats.hh index d111976cf..b12b2d71a 100644 --- a/src/base/cprintf_formats.hh +++ b/src/base/cprintf_formats.hh @@ -204,37 +204,26 @@ template inline void _format_string(std::ostream &out, const T &data, Format &fmt) { - using namespace std; - -#if defined(__GNUC__) && (__GNUC__ < 3) || 1 if (fmt.width > 0) { std::stringstream foo; foo << data; int flen = foo.str().size(); if (fmt.width > flen) { - char *spaces = new char[fmt.width - flen + 1]; - memset(spaces, ' ', fmt.width - flen); + char spaces[fmt.width - flen + 1]; + std::memset(spaces, ' ', fmt.width - flen); spaces[fmt.width - flen] = 0; if (fmt.flush_left) out << foo.str() << spaces; else out << spaces << foo.str(); - - delete [] spaces; - } else + } else { out << data; - } else + } + } else { out << data; -#else - if (fmt.width > 0) - out.width(fmt.width); - if (fmt.flush_left) - out.setf(std::ios::left); - - out << data; -#endif + } } /////////////////////////////////////////////////////////////////////////////