From 2f3d3fbd2403261c8afed1e5bd4e1fd005482921 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 11 Dec 2025 14:50:18 -0700 Subject: [PATCH] Add stream to buffer_group::output_unit constructor 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 --- gdb/buffered-streams.c | 6 +++--- gdb/buffered-streams.h | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gdb/buffered-streams.c b/gdb/buffered-streams.c index a9d3fcf4f5d..71122c7f237 100644 --- a/gdb/buffered-streams.c +++ b/gdb/buffered-streams.c @@ -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. */ diff --git a/gdb/buffered-streams.h b/gdb/buffered-streams.h index 0da2d8a8f43..9da45b08b6b 100644 --- a/gdb/buffered-streams.h +++ b/gdb/buffered-streams.h @@ -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. */ -- 2.47.3