Two simplifications in tui-layout.c

This patch simplifies some code in tui-layout.c.

In show_layout, all the layout settings can be handled by a single
switch statement.  In show_source_disasm_command and
show_source_or_disasm_and_command, there is no need to check the
current layout, as the caller has already done so.

gdb/ChangeLog
2019-08-13  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (show_layout): Unify all layout cases into a
	single switch.
	(show_source_disasm_command, show_source_or_disasm_and_command):
	Don't check current layout.
This commit is contained in:
Tom Tromey
2019-07-05 12:34:31 -06:00
parent 3f3ffe54e2
commit cc0c3ffbc9
2 changed files with 115 additions and 118 deletions

View File

@ -1,3 +1,10 @@
2019-08-13 Tom Tromey <tom@tromey.com>
* tui/tui-layout.c (show_layout): Unify all layout cases into a
single switch.
(show_source_disasm_command, show_source_or_disasm_and_command):
Don't check current layout.
2019-08-13 Tom Tromey <tom@tromey.com> 2019-08-13 Tom Tromey <tom@tromey.com>
* tui/tui-wingeneral.c (make_all_visible): Remove. * tui/tui-wingeneral.c (make_all_visible): Remove.

View File

@ -83,16 +83,13 @@ show_layout (enum tui_layout_type layout)
/* First make the current layout be invisible. */ /* First make the current layout be invisible. */
tui_make_all_invisible (); tui_make_all_invisible ();
tui_locator_win_info_ptr ()->make_visible (false); tui_locator_win_info_ptr ()->make_visible (false);
if (layout == SRC_DATA_COMMAND
|| layout == DISASSEM_DATA_COMMAND)
{
show_data (layout);
tui_refresh_all ();
}
else
{
switch (layout) switch (layout)
{ {
case SRC_DATA_COMMAND:
case DISASSEM_DATA_COMMAND:
show_data (layout);
tui_refresh_all ();
break;
/* Now show the new layout. */ /* Now show the new layout. */
case SRC_COMMAND: case SRC_COMMAND:
show_source_command (); show_source_command ();
@ -111,7 +108,6 @@ show_layout (enum tui_layout_type layout)
break; break;
} }
} }
}
} }
@ -500,8 +496,6 @@ show_disasm_command (void)
static void static void
show_source_disasm_command (void) show_source_disasm_command (void)
{ {
if (tui_current_layout () != SRC_DISASSEM_COMMAND)
{
int cmd_height, src_height, asm_height; int cmd_height, src_height, asm_height;
if (TUI_CMD_WIN != NULL) if (TUI_CMD_WIN != NULL)
@ -552,7 +546,6 @@ show_source_disasm_command (void)
make_visible, so we need this instead. */ make_visible, so we need this instead. */
tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW); tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
current_layout = SRC_DISASSEM_COMMAND; current_layout = SRC_DISASSEM_COMMAND;
}
} }
@ -630,8 +623,6 @@ tui_gen_win_info::reset (int height_, int width_,
static void static void
show_source_or_disasm_and_command (enum tui_layout_type layout_type) show_source_or_disasm_and_command (enum tui_layout_type layout_type)
{ {
if (tui_current_layout () != layout_type)
{
struct tui_source_window_base *win_info; struct tui_source_window_base *win_info;
int src_height, cmd_height; int src_height, cmd_height;
struct tui_locator_window *locator = tui_locator_win_info_ptr (); struct tui_locator_window *locator = tui_locator_win_info_ptr ();
@ -682,5 +673,4 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
make_visible, so we need this instead. */ make_visible, so we need this instead. */
tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW); tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
current_layout = layout_type; current_layout = layout_type;
}
} }