From c7b9987d081ae4e0103309b18c93deecc395dec9 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Tue, 2 Apr 2019 21:31:24 +0200 Subject: Codechange: Switch DropDownList to directly use std::vector, thus making AutoDeleteSmallVector obsolete. DropDownListItem are strongly managed using std::unique_ptr to ensure leak-free handling. Appropriate use of move-semantics make intent a lot clearer than parameter comments and allows the compiler to generate copy-free code for most situations. --- src/ai/ai_gui.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ai/ai_gui.cpp') diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 2730070c3..eaf2a9d83 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -479,12 +479,12 @@ struct AISettingsWindow : public Window { this->clicked_dropdown = true; this->closing_dropdown = false; - DropDownList *list = new DropDownList(); + DropDownList list; for (int i = config_item.min_value; i <= config_item.max_value; i++) { - list->push_back(new DropDownListCharStringItem(config_item.labels->Find(i)->second, i, false)); + list.emplace_back(new DropDownListCharStringItem(config_item.labels->Find(i)->second, i, false)); } - ShowDropDownListAt(this, list, old_val, -1, wi_rect, COLOUR_ORANGE, true); + ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE, true); } } } else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) { -- cgit v1.2.3-54-g00ecf