Changeset - r23522:1fb564b1efa6
[Not reviewed]
master
0 7 0
Henry Wilson - 6 years ago 2018-09-23 16:16:49
m3henry@googlemail.com
Codechange: Replaced SmallVector::Reset() with std::vector::clear() + shrink_to_fit()
7 files changed with 12 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/core/smallvec_type.hpp
Show inline comments
 
@@ -75,21 +75,12 @@ public:
 
		if ((const void *)&other == (void *)this) return;
 

	
 
		std::vector<T>::operator=(other);
 
	}
 

	
 
	/**
 
	 * Remove all items from the list and free allocated memory.
 
	 */
 
	inline void Reset()
 
	{
 
		std::vector<T>::clear();
 
		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/network/network_content.cpp
Show inline comments
 
@@ -552,13 +552,14 @@ void ClientNetworkContentSocketHandler::
 
void ClientNetworkContentSocketHandler::OnFailure()
 
{
 
	/* If we fail, download the rest via the 'old' system. */
 
	uint files, bytes;
 
	this->DownloadSelectedContent(files, bytes, true);
 

	
 
	this->http_response.Reset();
 
	this->http_response.clear();
 
	this->http_response.shrink_to_fit();
 
	this->http_response_index = -2;
 

	
 
	if (this->curFile != NULL) {
 
		/* Revert the download progress when we are going for the old system. */
 
		long size = ftell(this->curFile);
 
		if (size > 0) this->OnDownloadProgress(this->curInfo, (int)-size);
src/newgrf_engine.cpp
Show inline comments
 
@@ -1269,13 +1269,14 @@ void CommitVehicleListOrderChanges()
 
	uint index = 0;
 
	for (const EngineID *it = ordering.Begin(); it != idend; ++it, ++index) {
 
		Engine::Get(*it)->list_position = index;
 
	}
 

	
 
	/* Clear out the queue */
 
	_list_order_changes.Reset();
 
	_list_order_changes.clear();
 
	_list_order_changes.shrink_to_fit();
 
}
 

	
 
/**
 
 * Fill the grf_cache of the given vehicle.
 
 * @param v The vehicle to fill the cache for.
 
 */
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -143,13 +143,14 @@ void MoveWaypointsToBaseStations()
 
	FOR_ALL_VEHICLES(v) {
 
		if (v->type != VEH_TRAIN) continue;
 

	
 
		UpdateWaypointOrder(&v->current_order);
 
	}
 

	
 
	_old_waypoints.Reset();
 
	_old_waypoints.clear();
 
	_old_waypoints.shrink_to_fit();
 
}
 

	
 
static const SaveLoad _old_waypoint_desc[] = {
 
	SLE_CONDVAR(OldWaypoint, xy,         SLE_FILE_U16 | SLE_VAR_U32,  SL_MIN_VERSION, SLV_6),
 
	SLE_CONDVAR(OldWaypoint, xy,         SLE_UINT32,                  SLV_6, SL_MAX_VERSION),
 
	SLE_CONDVAR(OldWaypoint, town_index, SLE_UINT16,                 SLV_12, SLV_122),
src/stringfilter.cpp
Show inline comments
 
@@ -25,13 +25,14 @@ static const WChar STATE_QUOTE2 = '"';
 
/**
 
 * Set the term to filter on.
 
 * @param str Filter term
 
 */
 
void StringFilter::SetFilterTerm(const char *str)
 
{
 
	this->word_index.Reset();
 
	this->word_index.clear();
 
	this->word_index.shrink_to_fit();
 
	this->word_matches = 0;
 
	free(this->filter_buffer);
 

	
 
	assert(str != NULL);
 

	
 
	char *dest = MallocT<char>(strlen(str) + 1);
src/texteff.cpp
Show inline comments
 
@@ -105,13 +105,14 @@ void MoveAllTextEffects(uint delta_ms)
 
		te->MarkDirty(ZOOM_LVL_OUT_8X);
 
	}
 
}
 

	
 
void InitTextEffects()
 
{
 
	_text_effects.Reset();
 
	_text_effects.clear();
 
	_text_effects.shrink_to_fit();
 
}
 

	
 
void DrawTextEffects(DrawPixelInfo *dpi)
 
{
 
	/* Don't draw the text effects when zoomed out a lot */
 
	if (dpi->zoom > ZOOM_LVL_OUT_8X) return;
src/vehicle.cpp
Show inline comments
 
@@ -690,13 +690,14 @@ void ResetVehicleColourMap()
 
 */
 
typedef SmallMap<Vehicle *, bool, 4> AutoreplaceMap;
 
static AutoreplaceMap _vehicles_to_autoreplace;
 

	
 
void InitializeVehicles()
 
{
 
	_vehicles_to_autoreplace.Reset();
 
	_vehicles_to_autoreplace.clear();
 
	_vehicles_to_autoreplace.shrink_to_fit();
 
	ResetVehicleHash();
 
}
 

	
 
uint CountVehiclesInChain(const Vehicle *v)
 
{
 
	uint count = 0;
0 comments (0 inline, 0 general)