From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: RFA: use memcpy, not a loop
Date: Tue, 29 Jul 2008 19:14:00 -0000 [thread overview]
Message-ID: <m3zlo07bbf.fsf@fleche.redhat.com> (raw)
While debugging on the python branch I ran into a couple of loops that
can be replaced with memcpy. I find that this is easier to read and
it makes debugging a bit friendlier.
Built and tested on the compile farm (x86-64).
Ok?
Tom
2008-07-28 Tom Tromey <tromey@redhat.com>
* cli/cli-decode.c (lookup_cmd_1): Use memcpy.
(lookup_cmd_composition): Likewise.
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 6908314..5b1a7e0 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1112,11 +1112,7 @@ lookup_cmd_1 (char **text, struct cmd_list_element *clist,
command = (char *) alloca (len + 1);
- for (tmp = 0; tmp < len; tmp++)
- {
- char x = (*text)[tmp];
- command[tmp] = x;
- }
+ memcpy (command, *text, len);
command[len] = '\0';
/* Look it up. */
@@ -1468,11 +1464,7 @@ lookup_cmd_composition (char *text,
it's length is len). We copy this into a local temporary */
command = (char *) alloca (len + 1);
- for (tmp = 0; tmp < len; tmp++)
- {
- char x = text[tmp];
- command[tmp] = x;
- }
+ memcpy (command, text, len);
command[len] = '\0';
/* Look it up. */
next reply other threads:[~2008-07-29 19:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-29 19:14 Tom Tromey [this message]
2008-07-29 22:10 ` Michael Snyder
2008-07-29 22:11 ` Michael Snyder
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=m3zlo07bbf.fsf@fleche.redhat.com \
--to=tromey@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