diff options
author | Tom Tromey <tom@tromey.com> | 2019-07-13 16:24:48 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-08-20 16:45:50 -0600 |
commit | fa4dc567aec7664b3508dd9401b1fbb6d304f281 (patch) | |
tree | e0af80ec79a5725116d3bad98caa8366432ac500 /gdb | |
parent | ca02d7c8003ad020bb39f0b26dc93b661be67132 (diff) | |
download | gdb-fa4dc567aec7664b3508dd9401b1fbb6d304f281.zip gdb-fa4dc567aec7664b3508dd9401b1fbb6d304f281.tar.gz gdb-fa4dc567aec7664b3508dd9401b1fbb6d304f281.tar.bz2 |
Remove indirection from tui_data_window::regs_content
tui_data_window::regs_content is currently a vector of unique_ptr.
However, due to the way this is managed now, there is no need to keep
the pointers -- it can simply be a vector of the objects themselves.
This patch removes this extra layer of indirection.
2019-08-20 Tom Tromey <tom@tromey.com>
* tui/tui-regs.h (struct tui_data_window): Use
DISABLE_COPY_AND_ASSIGN.
<regs_content>: Change type, removing unique_ptr.
<tui_data_window>: Add move constructor.
* tui/tui-regs.c (tui_data_window::show_registers)
(tui_data_window::show_register_group)
(tui_data_window::display_registers_from)
(tui_data_window::display_registers_from)
(tui_data_window::first_data_item_displayed)
(tui_data_window::delete_data_content_windows)
(tui_data_window::rerender, tui_data_window::refresh_window)
(tui_data_window::check_register_values): Update.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 15 | ||||
-rw-r--r-- | gdb/tui/tui-regs.c | 51 | ||||
-rw-r--r-- | gdb/tui/tui-regs.h | 6 |
3 files changed, 38 insertions, 34 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e50995d..b49f8fd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,20 @@ 2019-08-20 Tom Tromey <tom@tromey.com> + * tui/tui-regs.h (struct tui_data_window): Use + DISABLE_COPY_AND_ASSIGN. + <regs_content>: Change type, removing unique_ptr. + <tui_data_window>: Add move constructor. + * tui/tui-regs.c (tui_data_window::show_registers) + (tui_data_window::show_register_group) + (tui_data_window::display_registers_from) + (tui_data_window::display_registers_from) + (tui_data_window::first_data_item_displayed) + (tui_data_window::delete_data_content_windows) + (tui_data_window::rerender, tui_data_window::refresh_window) + (tui_data_window::check_register_values): Update. + +2019-08-20 Tom Tromey <tom@tromey.com> + * tui/tui-regs.h (struct tui_data_window) <show_registers, show_register_group>: Declare. (tui_show_register_group): Don't declare. diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index 8adfb15..675e186 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -163,10 +163,7 @@ tui_data_window::show_registers (struct reggroup *group) /* Clear all notation of changed values. */ for (auto &&data_item_win : regs_content) - { - if (data_item_win != nullptr) - data_item_win->highlight = false; - } + data_item_win.highlight = false; current_group = group; display_all_data (); } @@ -214,16 +211,7 @@ tui_data_window::show_register_group (struct reggroup *group, nr_regs++; } - if (!refresh_values_only) - regs_content.clear (); - - if (nr_regs < regs_content.size ()) - regs_content.resize (nr_regs); - else - { - for (int i = regs_content.size (); i < nr_regs; ++i) - regs_content.emplace_back (new tui_data_item_window ()); - } + regs_content.resize (nr_regs); /* Now set the register names and values. */ pos = 0; @@ -242,7 +230,7 @@ tui_data_window::show_register_group (struct reggroup *group, if (name == 0 || *name == '\0') continue; - data_item_win = regs_content[pos].get (); + data_item_win = ®s_content[pos]; if (data_item_win) { if (!refresh_values_only) @@ -273,7 +261,7 @@ tui_data_window::display_registers_from (int start_element_no) int len; len = 0; - p = data_item_win->content.get (); + p = data_item_win.content.get (); if (p != 0) len = strlen (p); @@ -301,7 +289,7 @@ tui_data_window::display_registers_from (int start_element_no) struct tui_data_item_window *data_item_win; /* Create the window if necessary. */ - data_item_win = regs_content[i].get (); + data_item_win = ®s_content[i]; if (data_item_win->handle != NULL && (data_item_win->height != 1 || data_item_win->width != item_win_width @@ -408,7 +396,7 @@ tui_data_window::first_data_item_displayed () { struct tui_gen_win_info *data_item_win; - data_item_win = regs_content[i].get (); + data_item_win = ®s_content[i]; if (data_item_win->is_visible ()) return i; } @@ -423,8 +411,8 @@ tui_data_window::delete_data_content_windows () { for (auto &&win : regs_content) { - tui_delete_win (win->handle); - win->handle = NULL; + tui_delete_win (win.handle); + win.handle = NULL; } } @@ -523,8 +511,8 @@ tui_data_window::rerender () /* Delete all data item windows. */ for (auto &&win : regs_content) { - tui_delete_win (win->handle); - win->handle = NULL; + tui_delete_win (win.handle); + win.handle = NULL; } display_all_data (); } @@ -536,10 +524,7 @@ tui_data_window::refresh_window () { tui_gen_win_info::refresh_window (); for (auto &&win : regs_content) - { - if (win != NULL) - win->refresh_window (); - } + win.refresh_window (); } /* This function check all displayed registers for changes in values, @@ -552,18 +537,18 @@ tui_data_window::check_register_values (struct frame_info *frame) show_registers (current_group); else { - for (auto &&data_item_win_ptr : regs_content) + for (auto &&data_item_win : regs_content) { int was_hilighted; - was_hilighted = data_item_win_ptr->highlight; + was_hilighted = data_item_win.highlight; - tui_get_register (frame, data_item_win_ptr.get (), - data_item_win_ptr->item_no, - &data_item_win_ptr->highlight); + tui_get_register (frame, &data_item_win, + data_item_win.item_no, + &data_item_win.highlight); - if (data_item_win_ptr->highlight || was_hilighted) - tui_display_register (data_item_win_ptr.get ()); + if (data_item_win.highlight || was_hilighted) + tui_display_register (&data_item_win); } } } diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index e07abed..24ec587 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -33,6 +33,10 @@ struct tui_data_item_window : public tui_gen_win_info { } + DISABLE_COPY_AND_ASSIGN (tui_data_item_window); + + tui_data_item_window (tui_data_item_window &&) = default; + const char *name = nullptr; /* The register number, or data display number. */ int item_no = -1; @@ -60,7 +64,7 @@ struct tui_data_window : public tui_win_info } /* Windows that are used to display registers. */ - std::vector<std::unique_ptr<tui_data_item_window>> regs_content; + std::vector<tui_data_item_window> regs_content; int regs_column_count = 0; /* Should regs be displayed at all? */ bool display_regs = false; |