From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20859 invoked by alias); 29 Jul 2008 19:14:17 -0000 Received: (qmail 20850 invoked by uid 22791); 29 Jul 2008 19:14:17 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 29 Jul 2008 19:13:59 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m6TJDv2X008982 for ; Tue, 29 Jul 2008 15:13:57 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6TJDvkE026895; Tue, 29 Jul 2008 15:13:57 -0400 Received: from opsy.redhat.com (vpn-10-116.bos.redhat.com [10.16.10.116]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6TJDvpm004024; Tue, 29 Jul 2008 15:13:57 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 6E2C33784E3; Tue, 29 Jul 2008 13:13:56 -0600 (MDT) To: gdb-patches@sourceware.org Subject: RFA: use memcpy, not a loop From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom Date: Tue, 29 Jul 2008 19:14:00 -0000 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00544.txt.bz2 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 * 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. */