diff options
author | Michael Lutz <michi@icosahedron.de> | 2019-04-02 21:31:24 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2019-04-09 22:45:15 +0200 |
commit | c7b9987d081ae4e0103309b18c93deecc395dec9 (patch) | |
tree | e5b1f9553d6399e2eed9c05a2d91673205f9c912 /src/rail_gui.cpp | |
parent | d3e113eb5f618ce0174fa0dfa2591cb96e999350 (diff) | |
download | openttd-c7b9987d081ae4e0103309b18c93deecc395dec9.tar.xz |
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.
Diffstat (limited to 'src/rail_gui.cpp')
-rw-r--r-- | src/rail_gui.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 176e8e6ef..e3d307dc9 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1987,7 +1987,7 @@ void InitializeRailGUI() * @param all_option Whether to add an 'all types' item. * @return The populated and sorted #DropDownList. */ -DropDownList *GetRailTypeDropDownList(bool for_replacement, bool all_option) +DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option) { RailTypes used_railtypes; RailTypes avail_railtypes; @@ -2003,11 +2003,10 @@ DropDownList *GetRailTypeDropDownList(bool for_replacement, bool all_option) used_railtypes = GetRailTypes(true); } - DropDownList *list = new DropDownList(); + DropDownList list; if (all_option) { - DropDownListStringItem *item = new DropDownListStringItem(STR_REPLACE_ALL_RAILTYPE, INVALID_RAILTYPE, false); - list->push_back(item); + list.emplace_back(new DropDownListStringItem(STR_REPLACE_ALL_RAILTYPE, INVALID_RAILTYPE, false)); } Dimension d = { 0, 0 }; @@ -2038,7 +2037,7 @@ DropDownList *GetRailTypeDropDownList(bool for_replacement, bool all_option) } item->SetParam(0, rti->strings.menu_text); item->SetParam(1, rti->max_speed); - list->push_back(item); + list.emplace_back(item); } return list; } |