This is the mail archive of the 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 01/22] Change selttest.c to use use std::vector

>>>>> "Trevor" == Trevor Saunders <> writes:

Trevor> I'd agree, hopefully we can throw VEC in the trash some day.  Relatedly
Trevor> we should probably move gcc's hash table stuff to include/ sooner rather
Trevor> than later so we can similarly get rid of htab.

That would be nice; though we could probably use std::set and std::map
in gdb as well.  One wrinkle with hash tables is that they're sometimes
allocated on obstacks; would gcc's handle this?

>> for (auto f : tests)

Trevor> its debatable, but imho its not necessarily obvious what the type of the
Trevor> local is when you use auto to iterate over vectors especially when they
Trevor> are members or globals like here.

Yeah, that's one drawback.
Often one actually wants "auto &f" in there.

>> +static std::vector<self_test_function *> tests;

Trevor> should we use a pointer to avoid the static initializer?

I was on the fence about this one.
On the one hand, static initializers can be very bad.
On the other hand, this one in particular doesn't seem like it could
cause problems.

>> -  for (i = 0; VEC_iterate (self_test_function_ptr, tests, i, func); ++i)
>> +  for (std::vector<self_test_function *>::iterator iter = tests.begin ();
>> +       iter != tests.end ();
>> +       ++iter)

Trevor> I believe you can "cheat" here and just use the function pointer type,
Trevor> because the sane implementation of iterators over vectors is pointers.

Yeah, or just loop using an int and index into the vector.
I'll see if that looks cleaner.


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