From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] gdb: Use vector::emplace_back
Date: Wed, 09 Nov 2016 00:39:00 -0000 [thread overview]
Message-ID: <1478651991-5083-1-git-send-email-palves@redhat.com> (raw)
Now that we require C++11, we can use vector::emplace_back to
construct elements in place instead of constructing and then copying.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* main.c (struct cmdarg): Add constructor.
(captured_main_1): Use vector::emplace_back.
* tracepoint.c (collection_list::add_memrange): Likewise.
---
gdb/main.c | 31 ++++++++++---------------------
gdb/tracepoint.c | 2 +-
2 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/gdb/main.c b/gdb/main.c
index ca6a81e..fe57bf8 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -444,7 +444,12 @@ enum cmdarg_kind
};
/* Arguments of --command option and its counterpart. */
-struct cmdarg {
+struct cmdarg
+{
+ cmdarg (cmdarg_kind type_, char *string_)
+ : type (type_), string (string_)
+ {}
+
/* Type of this option. */
enum cmdarg_kind type;
@@ -745,32 +750,16 @@ captured_main_1 (struct captured_main_args *context)
pidarg = optarg;
break;
case 'x':
- {
- struct cmdarg cmdarg = { CMDARG_FILE, optarg };
-
- cmdarg_vec.push_back (cmdarg);
- }
+ cmdarg_vec.emplace_back (CMDARG_FILE, optarg);
break;
case 'X':
- {
- struct cmdarg cmdarg = { CMDARG_COMMAND, optarg };
-
- cmdarg_vec.push_back (cmdarg);
- }
+ cmdarg_vec.emplace_back (CMDARG_COMMAND, optarg);
break;
case OPT_IX:
- {
- struct cmdarg cmdarg = { CMDARG_INIT_FILE, optarg };
-
- cmdarg_vec.push_back (cmdarg);
- }
+ cmdarg_vec.emplace_back (CMDARG_INIT_FILE, optarg);
break;
case OPT_IEX:
- {
- struct cmdarg cmdarg = { CMDARG_INIT_COMMAND, optarg };
-
- cmdarg_vec.push_back (cmdarg);
- }
+ cmdarg_vec.emplace_back (CMDARG_INIT_COMMAND, optarg);
break;
case 'B':
batch_flag = batch_silent = 1;
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 3d28606..2a40b16 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -919,7 +919,7 @@ collection_list::add_memrange (int type, bfd_signed_vma base,
/* type: memrange_absolute == memory, other n == basereg */
/* base: addr if memory, offset if reg relative. */
/* len: we actually save end (base + len) for convenience */
- m_memranges.push_back (memrange (type, base, base + len));
+ m_memranges.emplace_back (type, base, base + len);
if (type != memrange_absolute) /* Better collect the base register! */
add_register (type);
--
2.5.5
next reply other threads:[~2016-11-09 0:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-09 0:39 Pedro Alves [this message]
2016-11-09 11:12 ` Yao Qi
2016-11-09 12:21 ` Pedro Alves
2016-11-09 12:43 ` Yao Qi
2016-11-09 12:55 ` Pedro Alves
2016-11-09 14:50 ` John Baldwin
2016-11-09 15:27 ` Pedro Alves
2016-11-09 17:08 ` John Baldwin
2016-11-09 18:45 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1478651991-5083-1-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox