diff options
author | Tom de Vries <tdevries@suse.de> | 2023-10-17 11:38:06 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-10-17 11:38:06 +0200 |
commit | 7e5649156720ec6c3aa5e2036b27811bc8195ab9 (patch) | |
tree | dd39720a56af95be020e6aea1b393377e1465bdf /gdb/source-cache.c | |
parent | 3233ad1e4e44530fa1088cef4790bdab6ee14944 (diff) | |
download | gdb-7e5649156720ec6c3aa5e2036b27811bc8195ab9.zip gdb-7e5649156720ec6c3aa5e2036b27811bc8195ab9.tar.gz gdb-7e5649156720ec6c3aa5e2036b27811bc8195ab9.tar.bz2 |
[gdb/cli] Skip string copy in source_cache::ensure
In function source_cache::ensure we have:
...
std::ostringstream output;
...
contents = output.str ();
...
The last line causes an unnecessary string copy.
C++20 allows us to skip it, like this:
...
contents = std::move (output).str ();
...
Use the more efficient solution.
Tested on x86_64-linux.
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Diffstat (limited to 'gdb/source-cache.c')
-rw-r--r-- | gdb/source-cache.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/source-cache.c b/gdb/source-cache.c index 77b357c..ae02d25 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -252,7 +252,7 @@ source_cache::ensure (struct symtab *s) std::istringstream input (contents); std::ostringstream output; highlighter->highlight (input, output, lang_name, fullname); - contents = output.str (); + contents = std::move (output).str (); already_styled = true; } catch (...) |