]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add stream to buffer_group::output_unit constructor
authorTom Tromey <tom@tromey.com>
Thu, 11 Dec 2025 21:50:18 +0000 (14:50 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 9 Feb 2026 15:09:10 +0000 (08:09 -0700)
I noticed that when creating a new output_unit, all the calls looked
like:

    m_buffered_output.emplace_back ("", indent).m_stream = stream;

It seems better to simply pass the stream to the constructor.

Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/buffered-streams.c
gdb/buffered-streams.h

index a9d3fcf4f5d44f79afa392ba277383dc377a8546..71122c7f23702404cba726678309c257abe69d95 100644 (file)
@@ -51,7 +51,7 @@ buffer_group::write (const char *buf, long length_buf, ui_file *stream)
            && m_buffered_output.back ().m_msg.back () != '\n')
          m_buffered_output.back ().m_msg.append (msg);
        else
-         m_buffered_output.emplace_back (msg).m_stream = stream;
+         m_buffered_output.emplace_back (stream, msg);
        prev = cur + 1;
       }
 }
@@ -61,7 +61,7 @@ buffer_group::write (const char *buf, long length_buf, ui_file *stream)
 void
 buffer_group::wrap_here (int indent, ui_file *stream)
 {
-  m_buffered_output.emplace_back ("", indent).m_stream = stream;
+  m_buffered_output.emplace_back (stream, "", indent);
 }
 
 /* See buffered-streams.h.  */
@@ -69,7 +69,7 @@ buffer_group::wrap_here (int indent, ui_file *stream)
 void
 buffer_group::flush_here (ui_file *stream)
 {
-  m_buffered_output.emplace_back ("", -1, true).m_stream = stream;
+  m_buffered_output.emplace_back (stream, "", -1, true);
 }
 
 /* See buffered-streams.h.  */
index 0da2d8a8f438d0f7d597e4b4d46ffed8dfb4d14a..9da45b08b6b4eaa1a1c1cf14d0a210f7e7573676 100644 (file)
@@ -48,8 +48,10 @@ private:
 
   struct output_unit
   {
-    output_unit (std::string msg, int wrap_hint = -1, bool flush = false)
-      : m_msg (msg), m_wrap_hint (wrap_hint), m_flush (flush)
+    output_unit (ui_file *stream, std::string msg, int wrap_hint = -1,
+                bool flush = false)
+      : m_stream (stream), m_msg (msg), m_wrap_hint (wrap_hint),
+       m_flush (flush)
     {}
 
     /* Write contents of this output_unit to the underlying stream.  */