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

@@ -3063,7 +3063,7 @@ struct IndustryCargoesWindow : public Window {
case WID_IC_CARGO_DROPDOWN: {
DropDownList lst;
for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
lst.emplace_back(new DropDownListStringItem(cs->name, cs->Index(), false));
lst.push_back(std::make_unique<DropDownListStringItem>(cs->name, cs->Index(), false));
}
if (!lst.empty()) {
int selected = (this->ind_cargo >= NUM_INDUSTRYTYPES) ? (int)(this->ind_cargo - NUM_INDUSTRYTYPES) : -1;
@@ -3077,7 +3077,7 @@ struct IndustryCargoesWindow : public Window {
for (IndustryType ind : _sorted_industry_types) {
const IndustrySpec *indsp = GetIndustrySpec(ind);
if (!indsp->enabled) continue;
lst.emplace_back(new DropDownListStringItem(indsp->name, ind, false));
lst.push_back(std::make_unique<DropDownListStringItem>(indsp->name, ind, false));
}
if (!lst.empty()) {
int selected = (this->ind_cargo < NUM_INDUSTRYTYPES) ? (int)this->ind_cargo : -1;