summaryrefslogtreecommitdiff
path: root/src/company_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/company_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/company_gui.cpp')
-rw-r--r--src/company_gui.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index a3f8a24b6..1c23a1251 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -602,18 +602,18 @@ private:
}
}
- DropDownList *list = new DropDownList();
+ DropDownList list;
if (default_livery != NULL) {
/* Add COLOUR_END to put the colour out of range, but also allow us to show what the default is */
default_col = (primary ? default_livery->colour1 : default_livery->colour2) + COLOUR_END;
- list->push_back(new DropDownListColourItem(default_col, false));
+ list.emplace_back(new DropDownListColourItem(default_col, false));
}
for (uint i = 0; i < lengthof(_colour_dropdown); i++) {
- list->push_back(new DropDownListColourItem(i, HasBit(used_colours, i)));
+ list.emplace_back(new DropDownListColourItem(i, HasBit(used_colours, i)));
}
byte sel = (default_livery == NULL || HasBit(livery->in_use, primary ? 0 : 1)) ? (primary ? livery->colour1 : livery->colour2) : default_col;
- ShowDropDownList(this, list, sel, widget);
+ ShowDropDownList(this, std::move(list), sel, widget);
}
static int CDECL GroupNameSorter(const Group * const *a, const Group * const *b)