From 9cba6f71936207f11ad0d4ed752d82966087fab9 Mon Sep 17 00:00:00 2001 From: Henry Wilson Date: Fri, 21 Sep 2018 22:45:44 +0100 Subject: [PATCH] Codechange: Replaced SmallVector::Compact() with std::vector::shrink_to_fit() --- src/build_vehicle_gui.cpp | 4 ++-- src/company_gui.cpp | 2 +- src/core/smallvec_type.hpp | 8 -------- src/fios.h | 2 +- src/graph_gui.cpp | 2 +- src/group_gui.cpp | 2 +- src/industry_gui.cpp | 2 +- src/network/network_content_gui.cpp | 2 +- src/network/network_gui.cpp | 2 +- src/newgrf_gui.cpp | 2 +- src/signs_gui.cpp | 2 +- src/station_gui.cpp | 2 +- src/story_gui.cpp | 4 ++-- src/town_gui.cpp | 2 +- src/vehiclelist.cpp | 6 +++--- 15 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index e160d6daca..f580ba7a92 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1345,7 +1345,7 @@ struct BuildVehicleWindow : Window { default: NOT_REACHED(); case VEH_TRAIN: this->GenerateBuildTrainList(); - this->eng_list.Compact(); + this->eng_list.shrink_to_fit(); this->eng_list.RebuildDone(); return; // trains should not reach the last sorting case VEH_ROAD: @@ -1364,7 +1364,7 @@ struct BuildVehicleWindow : Window { _engine_sort_direction = this->descending_sort_order; EngList_Sort(&this->eng_list, _engine_sort_functions[this->vehicle_type][this->sort_criteria]); - this->eng_list.Compact(); + this->eng_list.shrink_to_fit(); this->eng_list.RebuildDone(); } diff --git a/src/company_gui.cpp b/src/company_gui.cpp index ba82b44b8c..19aea17759 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -672,7 +672,7 @@ private: AddChildren(&list, INVALID_GROUP, 0); } - this->groups.Compact(); + this->groups.shrink_to_fit(); this->groups.RebuildDone(); } diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp index 89fdd13697..9ce63e3f3e 100644 --- a/src/core/smallvec_type.hpp +++ b/src/core/smallvec_type.hpp @@ -86,14 +86,6 @@ public: std::vector::shrink_to_fit(); } - /** - * Compact the list down to the smallest block size boundary. - */ - inline void Compact() - { - std::vector::shrink_to_fit(); - } - /** * Append an item and return it. * @param to_add the number of items to append diff --git a/src/fios.h b/src/fios.h index 788ac654f5..848fe7c8e1 100644 --- a/src/fios.h +++ b/src/fios.h @@ -191,7 +191,7 @@ public: /** Compact the list down to the smallest block size boundary. */ inline void Compact() { - this->files.Compact(); + this->files.shrink_to_fit(); } void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop); diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index c459e2a03b..a53bef906b 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -1143,7 +1143,7 @@ private: *this->companies.Append() = c; } - this->companies.Compact(); + this->companies.shrink_to_fit(); this->companies.RebuildDone(); } diff --git a/src/group_gui.cpp b/src/group_gui.cpp index bd8f37ec56..3a5aa0eead 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -184,7 +184,7 @@ private: AddChildren(&list, INVALID_GROUP, 0); - this->groups.Compact(); + this->groups.shrink_to_fit(); this->groups.RebuildDone(); } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 4fa3501284..eb6018973f 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -1209,7 +1209,7 @@ protected: *this->industries.Append() = i; } - this->industries.Compact(); + this->industries.shrink_to_fit(); this->industries.RebuildDone(); this->vscroll->SetCount(this->industries.Length()); // Update scrollbar as well. } diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 2ac7e6b12b..cb534d7961 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -397,7 +397,7 @@ class NetworkContentListWindow : public Window, ContentCallback { this->SetWidgetDisabledState(WID_NCL_SEARCH_EXTERNAL, this->auto_select && all_available); this->FilterContentList(); - this->content.Compact(); + this->content.shrink_to_fit(); this->content.RebuildDone(); this->SortContentList(); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 1366906b88..1451e7154e 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -267,7 +267,7 @@ protected: this->servers.SetFilterState(false); } - this->servers.Compact(); + this->servers.shrink_to_fit(); this->servers.RebuildDone(); this->vscroll->SetCount(this->servers.Length()); diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index fcb04be0d6..4235d31336 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -1481,7 +1481,7 @@ private: } this->avails.Filter(this->string_filter); - this->avails.Compact(); + this->avails.shrink_to_fit(); this->avails.RebuildDone(); this->avails.Sort(); diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index fab2ac912b..84b43c69d0 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -67,7 +67,7 @@ struct SignList { this->signs.SetFilterState(true); this->FilterSignList(); - this->signs.Compact(); + this->signs.shrink_to_fit(); this->signs.RebuildDone(); } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 965240e3ed..32e22b1616 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -202,7 +202,7 @@ protected: } } - this->stations.Compact(); + this->stations.shrink_to_fit(); this->stations.RebuildDone(); this->vscroll->SetCount(this->stations.Length()); // Update the scrollbar diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 0ccfe2b63d..efb3f36e72 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -61,7 +61,7 @@ protected: } } - this->story_pages.Compact(); + this->story_pages.shrink_to_fit(); this->story_pages.RebuildDone(); } @@ -90,7 +90,7 @@ protected: } } - this->story_page_elements.Compact(); + this->story_page_elements.shrink_to_fit(); this->story_page_elements.RebuildDone(); } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 5cc934f0a8..b9aa938e63 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -657,7 +657,7 @@ private: *this->towns.Append() = t; } - this->towns.Compact(); + this->towns.shrink_to_fit(); this->towns.RebuildDone(); this->vscroll->SetCount(this->towns.Length()); // Update scrollbar as well. } diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp index 4022262685..39ec90e8b9 100644 --- a/src/vehiclelist.cpp +++ b/src/vehiclelist.cpp @@ -103,8 +103,8 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine /* Ensure the lists are not wasting too much space. If the lists are fresh * (i.e. built within a command) then this will actually do nothing. */ - engines->Compact(); - if (wagons != NULL && wagons != engines) wagons->Compact(); + engines->shrink_to_fit(); + if (wagons != NULL && wagons != engines) wagons->shrink_to_fit(); } /** @@ -184,6 +184,6 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli default: return false; } - list->Compact(); + list->shrink_to_fit(); return true; }