Gabe Black has submitted this change. ( 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
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35977
Reviewed-by: Daniel Carvalho <[email protected]>
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/base/cprintf_formats.hh
1 file changed, 6 insertions(+), 17 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass



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: 3
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to