Changeset - r23518:3531e6987951
[Not reviewed]
master
0 15 0
Henry Wilson - 6 years ago 2018-09-21 21:45:44
m3henry@googlemail.com
Codechange: Replaced SmallVector::Compact() with std::vector::shrink_to_fit()
15 files changed with 18 insertions and 26 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1342,13 +1342,13 @@ struct BuildVehicleWindow : Window {
 
	{
 
		if (!this->eng_list.NeedRebuild()) return;
 
		switch (this->vehicle_type) {
 
			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:
 
				this->GenerateBuildRoadVehList();
 
				break;
 
			case VEH_SHIP:
 
@@ -1361,13 +1361,13 @@ struct BuildVehicleWindow : Window {
 

	
 
		this->FilterEngineList();
 

	
 
		_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();
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
 
		switch (widget) {
src/company_gui.cpp
Show inline comments
 
@@ -669,13 +669,13 @@ private:
 
			list.ForceResort();
 
			list.Sort(&GroupNameSorter);
 

	
 
			AddChildren(&list, INVALID_GROUP, 0);
 
		}
 

	
 
		this->groups.Compact();
 
		this->groups.shrink_to_fit();
 
		this->groups.RebuildDone();
 
	}
 

	
 
	void SetRows()
 
	{
 
		if (this->livery_class < LC_GROUP_RAIL) {
src/core/smallvec_type.hpp
Show inline comments
 
@@ -84,20 +84,12 @@ public:
 
	{
 
		std::vector<T>::clear();
 
		std::vector<T>::shrink_to_fit();
 
	}
 

	
 
	/**
 
	 * Compact the list down to the smallest block size boundary.
 
	 */
 
	inline void Compact()
 
	{
 
		std::vector<T>::shrink_to_fit();
 
	}
 

	
 
	/**
 
	 * Append an item and return it.
 
	 * @param to_add the number of items to append
 
	 * @return pointer to newly allocated item
 
	 */
 
	inline T *Append(uint to_add = 1)
 
	{
src/fios.h
Show inline comments
 
@@ -188,13 +188,13 @@ public:
 
		this->files.clear();
 
	}
 

	
 
	/** 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);
 
	const FiosItem *FindItem(const char *file);
 

	
 
	SmallVector<FiosItem, 32> files; ///< The list of files.
src/graph_gui.cpp
Show inline comments
 
@@ -1140,13 +1140,13 @@ private:
 

	
 
		const Company *c;
 
		FOR_ALL_COMPANIES(c) {
 
			*this->companies.Append() = c;
 
		}
 

	
 
		this->companies.Compact();
 
		this->companies.shrink_to_fit();
 
		this->companies.RebuildDone();
 
	}
 

	
 
	/** Sort the company league by performance history */
 
	static int CDECL PerformanceSorter(const Company * const *c1, const Company * const *c2)
 
	{
src/group_gui.cpp
Show inline comments
 
@@ -181,13 +181,13 @@ private:
 

	
 
		list.ForceResort();
 
		list.Sort(&GroupNameSorter);
 

	
 
		AddChildren(&list, INVALID_GROUP, 0);
 

	
 
		this->groups.Compact();
 
		this->groups.shrink_to_fit();
 
		this->groups.RebuildDone();
 
	}
 

	
 
	/**
 
	 * Compute tiny_step_height and column_size
 
	 * @return Total width required for the group list.
src/industry_gui.cpp
Show inline comments
 
@@ -1206,13 +1206,13 @@ protected:
 

	
 
			const Industry *i;
 
			FOR_ALL_INDUSTRIES(i) {
 
				*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.
 
		}
 

	
 
		if (!this->industries.Sort()) return;
 
		IndustryDirectoryWindow::last_industry = NULL; // Reset name sorter sort cache
src/network/network_content_gui.cpp
Show inline comments
 
@@ -394,13 +394,13 @@ class NetworkContentListWindow : public 
 
			*this->content.Append() = *iter;
 
		}
 

	
 
		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();
 

	
 
		this->vscroll->SetCount(this->content.Length()); // Update the scrollbar
 
		this->ScrollToSelected();
 
	}
src/network/network_gui.cpp
Show inline comments
 
@@ -264,13 +264,13 @@ protected:
 
			this->servers.SetFilterState(true);
 
			this->servers.Filter(sf);
 
		} else {
 
			this->servers.SetFilterState(false);
 
		}
 

	
 
		this->servers.Compact();
 
		this->servers.shrink_to_fit();
 
		this->servers.RebuildDone();
 
		this->vscroll->SetCount(this->servers.Length());
 

	
 
		/* Sort the list of network games as requested. */
 
		this->servers.Sort();
 
		this->UpdateListPos();
src/newgrf_gui.cpp
Show inline comments
 
@@ -1478,13 +1478,13 @@ private:
 
					*this->avails.Append() = c;
 
				}
 
			}
 
		}
 

	
 
		this->avails.Filter(this->string_filter);
 
		this->avails.Compact();
 
		this->avails.shrink_to_fit();
 
		this->avails.RebuildDone();
 
		this->avails.Sort();
 

	
 
		if (this->avail_sel != NULL) {
 
			this->avail_pos = this->avails.FindIndex(this->avail_sel);
 
			if (this->avail_pos < 0) this->avail_sel = NULL;
src/signs_gui.cpp
Show inline comments
 
@@ -64,13 +64,13 @@ struct SignList {
 

	
 
		const Sign *si;
 
		FOR_ALL_SIGNS(si) *this->signs.Append() = si;
 

	
 
		this->signs.SetFilterState(true);
 
		this->FilterSignList();
 
		this->signs.Compact();
 
		this->signs.shrink_to_fit();
 
		this->signs.RebuildDone();
 
	}
 

	
 
	/** Sort signs by their name */
 
	static int CDECL SignNameSorter(const Sign * const *a, const Sign * const *b)
 
	{
src/station_gui.cpp
Show inline comments
 
@@ -199,13 +199,13 @@ protected:
 
						*this->stations.Append() = st;
 
					}
 
				}
 
			}
 
		}
 

	
 
		this->stations.Compact();
 
		this->stations.shrink_to_fit();
 
		this->stations.RebuildDone();
 

	
 
		this->vscroll->SetCount(this->stations.Length()); // Update the scrollbar
 
	}
 

	
 
	/** Sort stations by their name */
src/story_gui.cpp
Show inline comments
 
@@ -58,13 +58,13 @@ protected:
 
			FOR_ALL_STORY_PAGES(p) {
 
				if (this->IsPageAvailable(p)) {
 
					*this->story_pages.Append() = p;
 
				}
 
			}
 

	
 
			this->story_pages.Compact();
 
			this->story_pages.shrink_to_fit();
 
			this->story_pages.RebuildDone();
 
		}
 

	
 
		this->story_pages.Sort();
 
	}
 

	
 
@@ -87,13 +87,13 @@ protected:
 
					if (pe->page == p->index) {
 
						*this->story_page_elements.Append() = pe;
 
					}
 
				}
 
			}
 

	
 
			this->story_page_elements.Compact();
 
			this->story_page_elements.shrink_to_fit();
 
			this->story_page_elements.RebuildDone();
 
		}
 

	
 
		this->story_page_elements.Sort();
 
	}
 

	
src/town_gui.cpp
Show inline comments
 
@@ -654,13 +654,13 @@ private:
 

	
 
			const Town *t;
 
			FOR_ALL_TOWNS(t) {
 
				*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.
 
		}
 
		/* Always sort the towns. */
 
		this->last_town = NULL;
 
		this->towns.Sort();
src/vehiclelist.cpp
Show inline comments
 
@@ -100,14 +100,14 @@ void BuildDepotVehicleList(VehicleType t
 

	
 
		*engines->Append() = v;
 
	}
 

	
 
	/* 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();
 
}
 

	
 
/**
 
 * Generate a list of vehicles based on window type.
 
 * @param list Pointer to list to add vehicles to
 
 * @param vli  The identifier of this vehicle list.
 
@@ -181,9 +181,9 @@ bool GenerateVehicleSortList(VehicleList
 
			}
 
			break;
 

	
 
		default: return false;
 
	}
 

	
 
	list->Compact();
 
	list->shrink_to_fit();
 
	return true;
 
}
0 comments (0 inline, 0 general)