Codechange: Avoid emplace_back(new()) into a unique_ptr. (#11384)

This could theoretically leave an unmanaged pointer in certain circumstances, and directly using
make_unique shows intent.
This commit is contained in:
2023-10-20 18:40:48 +01:00
committed by GitHub
parent 429a6f58e7
commit fd6f1e844a
21 changed files with 117 additions and 118 deletions

View File

@@ -75,14 +75,14 @@ struct SetDateWindow : Window {
case WID_SD_DAY:
for (uint i = 0; i < 31; i++) {
list.emplace_back(new DropDownListStringItem(STR_DAY_NUMBER_1ST + i, i + 1, false));
list.push_back(std::make_unique<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.emplace_back(new DropDownListStringItem(STR_MONTH_JAN + i, i, false));
list.push_back(std::make_unique<DropDownListStringItem>(STR_MONTH_JAN + i, i, false));
}
selected = this->date.month;
break;
@@ -90,7 +90,7 @@ struct SetDateWindow : Window {
case WID_SD_YEAR:
for (TimerGameCalendar::Year i = this->min_year; i <= this->max_year; i++) {
SetDParam(0, i);
list.emplace_back(new DropDownListStringItem(STR_JUST_INT, static_cast<int32_t>(i), false));
list.push_back(std::make_unique<DropDownListStringItem>(STR_JUST_INT, static_cast<int32_t>(i), false));
}
selected = static_cast<int32_t>(this->date.year);
break;