This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/5] cp-namespace.c cleanup pass: simplify cp_lookup_symbol_in_namespace
- From: Doug Evans <xdje42 at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Sun, 14 Dec 2014 21:55:26 -0800
- Subject: [PATCH 2/5] cp-namespace.c cleanup pass: simplify cp_lookup_symbol_in_namespace
- Authentication-results: sourceware.org; auth=none
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 <xdje42@gmail.com>
* cp-namespace.c (cp_lookup_symbol_in_namespace): Simplify.
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 1c52fa0..f917771 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