[Ada] Do not re-cache symbol-lookup result found from cache lookup.
authorJoel Brobecker <brobecker@adacore.com>
Mon, 2 Feb 2015 03:28:12 +0000 (07:28 +0400)
committerJoel Brobecker <brobecker@adacore.com>
Mon, 2 Feb 2015 03:28:12 +0000 (07:28 +0400)
When ada-lang.c:ada_lookup_symbol_list_worker finds a match in
the symbol cache, it caches the result again, which is unecessary.
This patch fixes the code to avoid that.

gdb/ChangeLog:

        PR gdb/17856:
        * ada-lang.c (ada_lookup_symbol_list_worker): Do not re-cache
        results found in the cache.

Tested on x86_64-linux, no regression.

gdb/ChangeLog
gdb/ada-lang.c

index e11ff78173b0cf1c886b2d4b4e42331394db3dc6..eadf2100955b8b23d430686b0c4b9cbe1741e9b4 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-02  Joel Brobecker  <brobecker@adacore.com>
+
+       PR gdb/17856:
+       * ada-lang.c (ada_lookup_symbol_list_worker): Do not re-cache
+       results found in the cache.
+
 2015-02-02  Joel Brobecker  <brobecker@adacore.com>
 
        PR gdb/17854:
index 921aed59575a24a9ca29ab88ebd5a7ee5ae9e85a..562627ac970575ddadbde54d0b0b5c14ff20c9ac 100644 (file)
@@ -5412,14 +5412,12 @@ ada_lookup_symbol_list_worker (const char *name0, const struct block *block0,
   const struct block *block;
   const char *name;
   const int wild_match_p = should_use_wild_match (name0);
-  int cacheIfUnique;
+  int syms_from_global_search = 0;
   int ndefns;
 
   obstack_free (&symbol_list_obstack, NULL);
   obstack_init (&symbol_list_obstack);
 
-  cacheIfUnique = 0;
-
   /* Search specified block and its superiors.  */
 
   name = name0;
@@ -5463,7 +5461,6 @@ ada_lookup_symbol_list_worker (const char *name0, const struct block *block0,
      already performed this search before.  If we have, then return
      the same result.  */
 
-  cacheIfUnique = 1;
   if (lookup_cached_symbol (name0, namespace, &sym, &block))
     {
       if (sym != NULL)
@@ -5471,6 +5468,8 @@ ada_lookup_symbol_list_worker (const char *name0, const struct block *block0,
       goto done;
     }
 
+  syms_from_global_search = 1;
+
   /* Search symbols from all global blocks.  */
  
   add_nonlocal_symbols (&symbol_list_obstack, name, namespace, 1,
@@ -5489,10 +5488,10 @@ done:
 
   ndefns = remove_extra_symbols (*results, ndefns);
 
-  if (ndefns == 0 && full_search)
+  if (ndefns == 0 && full_search && syms_from_global_search)
     cache_symbol (name0, namespace, NULL, NULL);
 
-  if (ndefns == 1 && full_search && cacheIfUnique)
+  if (ndefns == 1 && full_search && syms_from_global_search)
     cache_symbol (name0, namespace, (*results)[0].sym, (*results)[0].block);
 
   ndefns = remove_irrelevant_renamings (*results, ndefns, block0);
This page took 0.034844 seconds and 4 git commands to generate.