From patchwork Wed Dec 17 09:23:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 4294 Received: (qmail 14889 invoked by alias); 17 Dec 2014 09:24:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14878 invoked by uid 89); 17 Dec 2014 09:24:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 17 Dec 2014 09:24:36 +0000 Received: by mail-pa0-f51.google.com with SMTP id ey11so16079931pad.38 for ; Wed, 17 Dec 2014 01:24:34 -0800 (PST) X-Received: by 10.66.237.97 with SMTP id vb1mr66911163pac.97.1418808274617; Wed, 17 Dec 2014 01:24:34 -0800 (PST) Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by mx.google.com with ESMTPSA id m5sm3296162pdp.53.2014.12.17.01.24.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Dec 2014 01:24:33 -0800 (PST) From: Doug Evans To: gdb-patches@sourceware.org Subject: Re: [PATCH 2/5] cp-namespace.c cleanup pass: simplify cp_lookup_symbol_in_namespace References: Date: Wed, 17 Dec 2014 01:23:42 -0800 In-Reply-To: (Doug Evans's message of "Sun, 14 Dec 2014 21:55:26 -0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Doug Evans writes: > This patch is just a simplification of one function. > > Rather than having two calls to lookup_symbol_file, > the patch reduces it to just one. > > 2014-12-14 Doug Evans > > * cp-namespace.c (cp_lookup_symbol_in_namespace): Simplify. Hi. Here is a revised patch for current HEAD. 2014-12-17 Doug Evans * cp-namespace.c (cp_lookup_symbol_in_namespace): Simplify. diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index bcb2275..b3ecffb 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -317,21 +317,20 @@ cp_lookup_symbol_in_namespace (const char *namespace, const struct block *block, const domain_enum domain, int search) { - if (namespace[0] == '\0') - { - return lookup_symbol_file (name, block, domain, 0, search); - } - else - { - char *concatenated_name = alloca (strlen (namespace) + 2 - + strlen (name) + 1); + char *concatenated_name = NULL; + int is_anonymous = namespace[0] != '\0' && cp_is_in_anonymous (namespace); + if (namespace[0] != '\0') + { + concatenated_name = alloca (strlen (namespace) + 2 + + strlen (name) + 1); strcpy (concatenated_name, namespace); strcat (concatenated_name, "::"); strcat (concatenated_name, name); - return lookup_symbol_file (concatenated_name, block, domain, - cp_is_in_anonymous (namespace), search); + name = concatenated_name; } + + return lookup_symbol_file (name, block, domain, is_anonymous, search); } /* Used for cleanups to reset the "searched" flag incase