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]

[RFA/commit/Ada] Replace home-made string_vector struct with VEC


Hi Daniel,

> I've committed the patch as is, and will do the VEC replacement as
> a separate patch.

I gave your suggestion a try, and here is what I got. I like using
the VEC as I feel that it will be more robust in the long run than
my local home-made string_vector (even if the code that I wrote was
pretty simple to start with). Overall, it doesn't looks like much
less code, but that's mostly because of the copy that I have to make,
I think.

While working on this change, it made me wonder about a few things:

  1. Would it make sense to have standard VECs predefined somewhere?
     For instance, I wonder how often a VEC of strings will be useful
     in GDB...

  2. Would it make sense to expand the VEC API to have a method
     that will return a copy of the underlying array? After some
     thoughts, and a look at the current usage, it seemed to me
     that it didn't make much sense. I didn't see any other places
     where we need to make that copy, and making that copy is
     pretty simple.

What do you think of the patch? In hindsight, I think it has more
merit than I thought. So I think I'll commit it unless you see some
flaws in it.

2007-02-05  Joel Brobecker  <brobecker@adacore.com>

        * ada-lang.c: #include "vec.h".
        (struct string_vector, new_string_vector, string_vector_append):
        Delete.
        (char_ptr): New typedef.
        (DEF_VEC_P (char_ptr)): New VEC type.
        (symbol_completion_add): Update profile to take the new VEC type
        instead of the old string_vector structure. Update code accordingly.
        (ada_make_symbol_completion_list): Use the new VEC type instead of
        the old string_vector structure, and update the code accordingly.
        * Makefile.in (ada-lang.o): Add dependency on vec.h.

Tested on x86-linux. No regression.

-- 
Joel

Attachment: complete-VEC.diff
Description: Text document


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