diff options
author | glx <glx@openttd.org> | 2019-04-11 22:17:30 +0200 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2019-04-13 12:49:18 +0100 |
commit | b52561fd381e2c8230730e852406b85210993a98 (patch) | |
tree | 8419fbfe87c06c7427eccbaee0384e96a85bb909 /src/engine_gui.cpp | |
parent | 2db88953e7e0e521b4514f356038eeb36b299dff (diff) | |
download | openttd-b52561fd381e2c8230730e852406b85210993a98.tar.xz |
Codechange: use std::sort() in EngList_Sort[Partial]()
Diffstat (limited to 'src/engine_gui.cpp')
-rw-r--r-- | src/engine_gui.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 4e9dc30d9..eb14b5d8a 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -325,11 +325,8 @@ void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID eng */ void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare) { - size_t size = el->size(); - /* out-of-bounds access at the next line for size == 0 (even with operator[] at some systems) - * generally, do not sort if there are less than 2 items */ - if (size < 2) return; - QSortT(el->data(), size, compare); + if (el->size() < 2) return; + std::sort(el->begin(), el->end(), compare); } /** @@ -344,6 +341,6 @@ void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, ui if (num_items < 2) return; assert(begin < el->size()); assert(begin + num_items <= el->size()); - QSortT(el->data() + begin, num_items, compare); + std::sort(el->begin() + begin, el->begin() + begin + num_items, compare); } |