Re: [PATCH 13/22] Replace hand-made linked list of ui_out_hdr by vector and iterator

Simon Marchi
2016-12-01T20:22:43Z

On 2016-11-26 11:13, Simon Marchi wrote:
> On 2016-11-24 13:41, Pedro Alves wrote:
>> On 11/24/2016 03:27 PM, Simon Marchi wrote:
>>> Instead of keeping pointers to first, last and current ui_out_hdr in
>>> ui_out_table, we can use an std::vector and an iterator. Direct
>>> random
>>> access of to vector helps make get_next_header a bit nicer by
>>> avoiding
>>> iterating on all the headers. append_header_to_list is also a bit
>>> simpler.
>>
>> Inserting into a vector invalidates iterators if it causes
>> reallocation.
>> I think we're good because there's be some call to start_body
>> or start_row before the iterator is ever dereferenced, right?
>>
>> Thanks,
>> Pedro Alves
>
> start_body and start_row is the terminology introduced in a later
> patch, but you are right. The table generation is in two phases:
>
> 1. define the headers
> 2. generate the body/rows
>
> In 1, we modify the vector but don't use the iterator, whereas in 2 we
> use the iterator but don't modify the vector. The various table state
> checks should validate that we don't try to define a new header while
> we are in phase 2, for example.

Just to be sure, is this patch OK?