Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/35977 )

Change subject: base: Clean up some #ifs in _format_string.
......................................................................

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
---
M src/base/cprintf_formats.hh
1 file changed, 6 insertions(+), 17 deletions(-)



diff --git a/src/base/cprintf_formats.hh b/src/base/cprintf_formats.hh
index d111976..b12b2d7 100644
--- a/src/base/cprintf_formats.hh
+++ b/src/base/cprintf_formats.hh
@@ -204,37 +204,26 @@
 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
+    }
 }

/////////////////////////////////////////////////////////////////////////////

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/35977
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I8df73a378f478413c111a4dea962450a37fb4092
Gerrit-Change-Number: 35977
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to