diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2020-10-05 09:02:42 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2020-10-05 09:03:09 -0400 |
commit | 7d1441178ac6d5b31e3ebf312012c2d5bfaeec91 (patch) | |
tree | 752eb8287e0296cf2f176b3fbf4659a91345b49a | |
parent | 6d96a5946d1ec76fea79bc36aa95d7d3dd304200 (diff) | |
download | gdb-7d1441178ac6d5b31e3ebf312012c2d5bfaeec91.zip gdb-7d1441178ac6d5b31e3ebf312012c2d5bfaeec91.tar.gz gdb-7d1441178ac6d5b31e3ebf312012c2d5bfaeec91.tar.bz2 |
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
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/auto-load.c | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 57e8cc7..39a2cf3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +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> * amd64-windows-tdep.c (amd64_windows_passed_by_integer_register): diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 9a51d2f..43d007c 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -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. */ if (HAS_DRIVE_SPEC (debugfile)) - { - debugfile_holder = STRIP_DRIVE_SPEC (debugfile); - filename = std::string("\\") + debugfile[0] + debugfile_holder; - } + filename = (std::string("\\") + debugfile[0] + + STRIP_DRIVE_SPEC (debugfile)); for (const gdb::unique_xmalloc_ptr<char> &dir : vec) { |