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>
* 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. */
tui_make_all_invisible ();
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)
{
case SRC_DATA_COMMAND:
case DISASSEM_DATA_COMMAND:
show_data (layout);
tui_refresh_all ();
break;
/* Now show the new layout. */
case SRC_COMMAND:
show_source_command ();
@ -112,7 +109,6 @@ show_layout (enum tui_layout_type layout)
}
}
}
}
/* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
@ -499,8 +495,6 @@ show_disasm_command (void)
/* Show the Source/Disassem/Command layout. */
static void
show_source_disasm_command (void)
{
if (tui_current_layout () != SRC_DISASSEM_COMMAND)
{
int cmd_height, src_height, asm_height;
@ -553,7 +547,6 @@ show_source_disasm_command (void)
tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
current_layout = SRC_DISASSEM_COMMAND;
}
}
/* Show the Source/Data/Command or the Dissassembly/Data/Command
@ -629,8 +622,6 @@ tui_gen_win_info::reset (int height_, int width_,
/* Show the Source/Command or the Disassem layout. */
static void
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;
int src_height, cmd_height;
@ -683,4 +674,3 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
current_layout = layout_type;
}
}