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: [RFA 05/15] Simplify calls to init_psymbol_list


On 2018-05-10 06:23 PM, Tom Tromey wrote:
> diff --git a/gdb/psymtab.c b/gdb/psymtab.c
> index 4fd47bf92b..c1c8cba800 100644
> --- a/gdb/psymtab.c
> +++ b/gdb/psymtab.c
> @@ -1725,14 +1725,14 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name,
>    append_psymbol_to_list (list, psym, objfile);
>  }
>  
> -/* Initialize storage for partial symbols.  */
> +/* See psympriv.h.  */
>  
>  void
>  init_psymbol_list (struct objfile *objfile, int total_symbols)
>  {
> -  /* Free any previously allocated psymbol lists.  */
> -  objfile->global_psymbols.clear ();
> -  objfile->static_psymbols.clear ();
> +  if (objfile->global_psymbols.capacity () == 0
> +      && objfile->static_psymbols.capacity () == 0)
> +    return;

Hmm, isn't the condition backwards?  If the capacity is zero, we want to
reserve some space.  But maybe we can skip the check completely... if we
have already reserved the same space previously, calling reserve again
does nothing (is harmless).

Would LGTM with the condition fixed (assuming I am not the one being confused)
or removed.

Simon


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