Skip to content
Snippets Groups Projects
Commit 7d144117 authored by Simon Marchi's avatar Simon Marchi
Browse files

gdb: avoid unnecessary string copy in auto_load_objfile_script_1

Assigning the result of STRIP_DRIVE_SPEC to an std::string creates an
unnecessary copy of the string.  STRIP_DRIVE_SPEC is defined as:

  #define STRIP_DRIVE_SPEC(f) ((f) + 2)

So if it is passed a "const char *", it returns a "const char *".  We
could use a "const char *" intermediary variable instead of an
std::string, or (as implemented in this patch) just use it directly in
the concatenation right after.

gdb/ChangeLog:

	* auto-load.c (auto_load_objfile_script_1): Don't use
	debugfile_holder as temporary variable when stripping drive
	letter.

Change-Id: If2ccc7a156b22100754d9cdf6778ac7eeb93da4c
parent 6d96a594
No related branches found
No related tags found
No related merge requests found
2020-10-05 Simon Marchi <simon.marchi@polymtl.ca>
* auto-load.c (auto_load_objfile_script_1): Don't use
debugfile_holder as temporary variable when stripping drive
letter.
2020-10-05 Hannes Domani <ssbssa@yahoo.de> 2020-10-05 Hannes Domani <ssbssa@yahoo.de>
   
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register): * amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
......
...@@ -777,10 +777,8 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname, ...@@ -777,10 +777,8 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
/* Convert Windows file name from c:/dir/file to /c/dir/file. */ /* Convert Windows file name from c:/dir/file to /c/dir/file. */
if (HAS_DRIVE_SPEC (debugfile)) if (HAS_DRIVE_SPEC (debugfile))
{ filename = (std::string("\\") + debugfile[0]
debugfile_holder = STRIP_DRIVE_SPEC (debugfile); + STRIP_DRIVE_SPEC (debugfile));
filename = std::string("\\") + debugfile[0] + debugfile_holder;
}
for (const gdb::unique_xmalloc_ptr<char> &dir : vec) for (const gdb::unique_xmalloc_ptr<char> &dir : vec)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment