From edf8b34026c564e28ac715af8bc8088ed9c6e94f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 14 Oct 2020 01:21:41 -0700 Subject: [PATCH] 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 --- src/base/cprintf_formats.hh | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) 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 + } } ///////////////////////////////////////////////////////////////////////////// -- 2.30.2