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: [PATCH 18/22] ui_out_table: Replace boolean flag with enum


On 11/24/2016 03:27 PM, Simon Marchi wrote:
> This patch is just a little cleanup, it replaces the body_flag field of
> ui_out_table with an enum.  It expresses more explicitly the
> intent of the field (check that state == TABLE_STATE_HEADERS conveys
> more what we want to do than checking for !body_flag).

Yay for avoiding the boolean trap.


> @@ -271,7 +279,7 @@ ui_out_table_begin (struct ui_out *uiout, int nbrofcols,
>  previous table_end."));
>  
>    uiout->table.flag = 1;
> -  uiout->table.body_flag = 0;
> +  uiout->table.state = ui_out_table_state::TABLE_STATE_HEADERS;

Nit: This one stood out, as none of the other places fully qualify
the enum.

You could also consider moving the enum to within
the table class, and/and use "enum class" to shorten the
names, if you want to scope it.

Thanks,
Pedro Alves


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