This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH/obvious] Little optimization on symbol_demangled_name


On Fri, 01 Jun 2012 06:41:49 +0200, Sergio Durigan Junior wrote:
> Regtested on Fedora 16 x86_64, no regressions.  I believe
> it's pretty obvious, but decided to check.  OK?

Yes.


> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index 85ddd1d..6313372 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -850,6 +850,8 @@ symbol_natural_name (const struct general_symbol_info *gsymbol)
>  const char *
>  symbol_demangled_name (const struct general_symbol_info *gsymbol)
>  {
> +  const char *dem_name = NULL;
> +
>    switch (gsymbol->language)
>      {
>      case language_cplus:
> @@ -858,19 +860,19 @@ symbol_demangled_name (const struct general_symbol_info *gsymbol)
>      case language_java:
>      case language_objc:
>      case language_fortran:
> -      if (symbol_get_demangled_name (gsymbol) != NULL)
> -	return symbol_get_demangled_name (gsymbol);
> +      dem_name = symbol_get_demangled_name (gsymbol);
>        break;
>      case language_ada:
> -      if (symbol_get_demangled_name (gsymbol) != NULL)
> -	return symbol_get_demangled_name (gsymbol);
> +      dem_name = symbol_get_demangled_name (gsymbol);

> +      if (dem_name != NULL)
> +	return dem_name;
>        else
>  	return ada_decode_symbol (gsymbol);

These 4 lines can be then for example just:

         if (dem_name == NULL)
	   dem_name = ada_decode_symbol (gsymbol);

>        break;
>      default:
>        break;
>      }
> -  return NULL;
> +  return dem_name;
>  }
>  
>  /* Return the search name of a symbol---generally the demangled or


Thanks,
Jan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]