Use iterators again for removing empty headings

Improving on f00aa15096, continue to use iterator and just set it to the result of erase.
This commit is contained in:
Ted John 2018-03-10 13:58:49 +00:00
parent f00aa15096
commit 74228ed35f
1 changed files with 6 additions and 6 deletions

View File

@ -681,16 +681,16 @@ static void initialise_list_items(rct_window *w)
_listItems.pop_back(); _listItems.pop_back();
// Remove empty headings // Remove empty headings
for (size_t i = 0; i < _listItems.size(); i++) for (auto it = _listItems.begin(); it != _listItems.end(); it++)
{ {
const auto &listItem = _listItems[i]; const auto &listItem = *it;
if (listItem.type == LIST_ITEM_TYPE::HEADING) if (listItem.type == LIST_ITEM_TYPE::HEADING)
{ {
if (i + 1 == _listItems.size() || if ((it + 1) == _listItems.end() ||
_listItems[i + 1].type == LIST_ITEM_TYPE::HEADING) (it + 1)->type == LIST_ITEM_TYPE::HEADING)
{ {
_listItems.erase(_listItems.begin() + i); it = _listItems.erase(it);
i--; it--;
} }
} }
} }