From: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Use string_file::release in some places
Date: Thu, 21 Sep 2023 13:42:07 -0600 [thread overview]
Message-ID: <20230921194207.2401885-1-tromey@adacore.com> (raw)
I found a few spots like:
string_file f;
std::string x = f.string ();
However, string_file::string returns a 'const std::string &'... so it
seems to me that this must be copying the string (? I find it hard to
reason about this in C++).
This patch changes these spots to use release() instead, which moves
the string.
---
gdb/breakpoint.c | 2 +-
gdb/top.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index d807ae3c9b5..f9b20a7d62d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -7581,7 +7581,7 @@ bp_location::to_string () const
string_file stb;
ui_out_redirect_pop redir (current_uiout, &stb);
print_breakpoint_location (this->owner, this);
- return stb.string ();
+ return stb.release ();
}
/* Decrement reference count. If the reference count reaches 0,
diff --git a/gdb/top.c b/gdb/top.c
index 2322e55f1db..cbe14b01046 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -647,12 +647,12 @@ execute_fn_to_string (std::string &res, std::function<void(void)> fn,
catch (...)
{
/* Finally. */
- res = std::move (str_file.string ());
+ res = str_file.release ();
throw;
}
/* And finally. */
- res = std::move (str_file.string ());
+ res = str_file.release ();
}
/* See gdbcmd.h. */
--
2.40.1
next reply other threads:[~2023-09-21 19:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-21 19:42 Tom Tromey via Gdb-patches [this message]
2023-09-22 20:42 ` Keith Seitz via Gdb-patches
2023-09-25 9:40 ` Lancelot SIX via Gdb-patches
2023-09-26 12:59 ` Tom Tromey via Gdb-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230921194207.2401885-1-tromey@adacore.com \
--to=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox