summaryrefslogtreecommitdiff
path: root/src/date_gui.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2019-04-02 21:31:24 +0200
committerMichael Lutz <michi@icosahedron.de>2019-04-09 22:45:15 +0200
commitc7b9987d081ae4e0103309b18c93deecc395dec9 (patch)
treee5b1f9553d6399e2eed9c05a2d91673205f9c912 /src/date_gui.cpp
parentd3e113eb5f618ce0174fa0dfa2591cb96e999350 (diff)
downloadopenttd-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/date_gui.cpp')
-rw-r--r--src/date_gui.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/date_gui.cpp b/src/date_gui.cpp
index d55e7e2b3..900e42bd7 100644
--- a/src/date_gui.cpp
+++ b/src/date_gui.cpp
@@ -68,21 +68,21 @@ struct SetDateWindow : Window {
void ShowDateDropDown(int widget)
{
int selected;
- DropDownList *list = new DropDownList();
+ DropDownList list;
switch (widget) {
default: NOT_REACHED();
case WID_SD_DAY:
for (uint i = 0; i < 31; i++) {
- list->push_back(new DropDownListStringItem(STR_DAY_NUMBER_1ST + i, i + 1, false));
+ list.emplace_back(new DropDownListStringItem(STR_DAY_NUMBER_1ST + i, i + 1, false));
}
selected = this->date.day;
break;
case WID_SD_MONTH:
for (uint i = 0; i < 12; i++) {
- list->push_back(new DropDownListStringItem(STR_MONTH_JAN + i, i, false));
+ list.emplace_back(new DropDownListStringItem(STR_MONTH_JAN + i, i, false));
}
selected = this->date.month;
break;
@@ -91,13 +91,13 @@ struct SetDateWindow : Window {
for (Year i = this->min_year; i <= this->max_year; i++) {
DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
item->SetParam(0, i);
- list->push_back(item);
+ list.emplace_back(item);
}
selected = this->date.year;
break;
}
- ShowDropDownList(this, list, selected, widget);
+ ShowDropDownList(this, std::move(list), selected, widget);
}
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override