Re: [RFA 2/6] gmp-utils: Convert the read/write methods to using gdb::array_view

Simon Marchi
2020-11-16T00:52:59Z

On 2020-11-15 3:49 a.m., Joel Brobecker wrote:
> This commit changes the interfaces of some of the methods declared
> in gmp-utils to take a gdb::array_view of gdb_byte instead of a
> (gdb_byte *, size) couple.
>
> This makes these methods' API probably more C++-idiomatic.
> With the way things are structured, this change introduces a minor
> extra complication at the point of call of these methods, since
> the data available there is not in the form of an array_view,
> and thus the array_view needs to be constructed on the spot.

I'd suggest using gdb::make_array_view (ptr, len) instead of the
array_view constructor. This way, you don't need to specify the
template type, it's automatically deduced, so it's a bit less verbose.
Otherwise, LGTM.

To alleviate the need to create array_view at all these points, I could
very well imagine (as a future change that would probably be quite
invasive) that the various value_contents functions could return
array_view instead of plain pointers.

Simon