From 5d10a2041eb843fd321ce1d850cf3e0df7648bc7 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 24 Jan 2022 20:00:46 -0500 Subject: gdb: add string_file::release method A common pattern for string_file is to want to move out the internal string buffer, because it is the result of the computation that we want to return. It is the reason why string_file::string returns a non-const reference, as explained in the comment. I think it would make sense to have a dedicated method for that instead and make string_file::string return a const reference. This allows removing the explicit std::move in the typical case. Note that compile_program::compute was missing a move, meaning that the resulting string was copied. With the new version, it's not possible to forget to move. Change-Id: Ieaefa35b73daa7930b2f3a26988b6e3b4121bb79 --- gdb/guile/scm-type.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gdb/guile') diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index c23305a..987660c 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -109,7 +109,7 @@ tyscm_type_name (struct type *type) string_file stb; LA_PRINT_TYPE (type, "", &stb, -1, 0, &type_print_raw_options); - return std::move (stb.string ()); + return stb.release (); } catch (const gdb_exception &except) { -- cgit v1.1