gdb: remove unnecessary call to std::string constructor
Commit Message
I spotted this explicit call to std::string, which creates an
unnecessary temporary extra std::string, while calling emplace_back.
I'm not sure if it has any impact in an optimized build, maybe the
compiler elides it. But still, it's unnecessary.
Change-Id: I873337ea91db29ac06267aff8fc12dcf52824cac
---
gdb/cli/cli-decode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
base-commit: b7ea736a38013510cd0496b42a8eb2dd2d2f6830
Comments
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
Simon> I spotted this explicit call to std::string, which creates an
Simon> unnecessary temporary extra std::string, while calling emplace_back.
Simon> I'm not sure if it has any impact in an optimized build, maybe the
Simon> compiler elides it. But still, it's unnecessary.
It probably just moves the new string, but I agree it's better with your patch.
Tom
On 5/12/23 14:44, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Simon> I spotted this explicit call to std::string, which creates an
> Simon> unnecessary temporary extra std::string, while calling emplace_back.
> Simon> I'm not sure if it has any impact in an optimized build, maybe the
> Simon> compiler elides it. But still, it's unnecessary.
>
> It probably just moves the new string, but I agree it's better with your patch.
Thanks, pushed.
Simon
@@ -155,7 +155,7 @@ cmd_list_element::command_components () const
if (this->prefix != nullptr)
result = this->prefix->command_components ();
- result.emplace_back (std::string (this->name));
+ result.emplace_back (this->name);
return result;
}