From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9513 invoked by alias); 3 Nov 2009 20:10:32 -0000 Received: (qmail 9500 invoked by uid 22791); 3 Nov 2009 20:10:32 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 Nov 2009 20:10:28 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA3KAQ8V017128 for ; Tue, 3 Nov 2009 15:10:27 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nA3KAQgL010803; Tue, 3 Nov 2009 15:10:26 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id nA3KAPQI020570; Tue, 3 Nov 2009 15:10:25 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 173F43782A4; Tue, 3 Nov 2009 13:10:25 -0700 (MST) From: Tom Tromey To: gdb-patches@sourceware.org Subject: FYI: minor simplification in add_psymbol_to_bcache Reply-To: Tom Tromey Date: Tue, 03 Nov 2009 20:10:00 -0000 Message-ID: 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: 2009-11/txt/msg00066.txt.bz2 This patch changes add_psymbol_to_bcache in two ways. First, it removes the gratuitous use of a 'static' local variable. Second, it removes the copying of 'name'. I think this copy is not needed because SYMBOL_SET_NAMES handles this case itself. Built and regtested on x86-64 (compile farm). I'll wait a while in case anybody has any comments on this. Tom 2009-11-03 Tom Tromey * symfile.c (add_psymbol_to_bcache): Don't copy name. Make 'psymbol' non-static. Index: symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.251 diff -u -r1.251 symfile.c --- symfile.c 2 Nov 2009 14:59:51 -0000 1.251 +++ symfile.c 3 Nov 2009 20:08:33 -0000 @@ -3106,19 +3106,9 @@ enum language language, struct objfile *objfile, int *added) { - char *buf = name; - /* psymbol is static so that there will be no uninitialized gaps in the - structure which might contain random data, causing cache misses in - bcache. */ - static struct partial_symbol psymbol; - - if (name[namelength] != '\0') - { - buf = alloca (namelength + 1); - /* Create local copy of the partial symbol */ - memcpy (buf, name, namelength); - buf[namelength] = '\0'; - } + struct partial_symbol psymbol; + + memset (&psymbol, 0, sizeof (struct partial_symbol)); /* val and coreaddr are mutually exclusive, one of them *will* be zero */ if (val != 0) { @@ -3133,7 +3123,7 @@ PSYMBOL_DOMAIN (&psymbol) = domain; PSYMBOL_CLASS (&psymbol) = class; - SYMBOL_SET_NAMES (&psymbol, buf, namelength, objfile); + SYMBOL_SET_NAMES (&psymbol, name, namelength, objfile); /* Stash the partial symbol away in the cache */ return bcache_full (&psymbol, sizeof (struct partial_symbol),