Codechange: Replace SmallVector::Clear() with std::vector::clear()

This commit is contained in:
Henry Wilson 2018-09-20 23:44:14 +01:00 committed by PeterN
parent 4b349c0f90
commit bfd79e59dc
47 changed files with 80 additions and 88 deletions

View File

@ -75,5 +75,5 @@ void AnimateAnimatedTiles()
*/
void InitializeAnimatedTiles()
{
_animated_tiles.Clear();
_animated_tiles.clear();
}

View File

@ -123,7 +123,7 @@ class ReplaceVehicleWindow : public Window {
byte side = draw_left ? 0 : 1;
GUIEngineList *list = &this->engines[side];
list->Clear();
list->clear();
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, type) {
@ -170,7 +170,7 @@ class ReplaceVehicleWindow : public Window {
/* Either we got a request to rebuild the right engines list, or the left engines list selected a different engine */
if (this->sel_engine[0] == INVALID_ENGINE) {
/* Always empty the right engines list when nothing is selected in the left engines list */
this->engines[1].Clear();
this->engines[1].clear();
this->sel_engine[1] = INVALID_ENGINE;
} else {
if (this->reset_sel_engine && this->sel_engine[0] != INVALID_ENGINE) {

View File

@ -1228,7 +1228,7 @@ struct BuildVehicleWindow : Window {
this->filter.railtype = (this->listview_mode) ? RAILTYPE_END : GetRailType(this->window_number);
this->eng_list.Clear();
this->eng_list.clear();
/* Make list of all available train engines and wagons.
* Also check to see if the previously selected engine is still available,
@ -1276,7 +1276,7 @@ struct BuildVehicleWindow : Window {
{
EngineID sel_id = INVALID_ENGINE;
this->eng_list.Clear();
this->eng_list.clear();
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
@ -1295,7 +1295,7 @@ struct BuildVehicleWindow : Window {
void GenerateBuildShipList()
{
EngineID sel_id = INVALID_ENGINE;
this->eng_list.Clear();
this->eng_list.clear();
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, VEH_SHIP) {
@ -1314,7 +1314,7 @@ struct BuildVehicleWindow : Window {
{
EngineID sel_id = INVALID_ENGINE;
this->eng_list.Clear();
this->eng_list.clear();
const Station *st = this->listview_mode ? NULL : Station::GetByTile(this->window_number);

View File

@ -469,7 +469,7 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags,
/* only execute the test call if it's toplevel, or we're not execing. */
if (_docommand_recursive == 1 || !(flags & DC_EXEC) ) {
if (_docommand_recursive == 1) _cleared_object_areas.Clear();
if (_docommand_recursive == 1) _cleared_object_areas.clear();
SetTownRatingTestMode(true);
res = proc(tile, flags & ~DC_EXEC, p1, p2, text);
SetTownRatingTestMode(false);
@ -492,7 +492,7 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags,
/* Execute the command here. All cost-relevant functions set the expenses type
* themselves to the cost object at some point */
if (_docommand_recursive == 1) _cleared_object_areas.Clear();
if (_docommand_recursive == 1) _cleared_object_areas.clear();
res = proc(tile, flags, p1, p2, text);
if (res.Failed()) {
error:
@ -666,7 +666,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
bool test_and_exec_can_differ = (cmd_flags & CMD_NO_TEST) != 0;
/* Test the command. */
_cleared_object_areas.Clear();
_cleared_object_areas.clear();
SetTownRatingTestMode(true);
BasePersistentStorageArray::SwitchMode(PSM_ENTER_TESTMODE);
CommandCost res = proc(tile, flags, p1, p2, text);
@ -710,7 +710,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
/* Actually try and execute the command. If no cost-type is given
* use the construction one */
_cleared_object_areas.Clear();
_cleared_object_areas.clear();
BasePersistentStorageArray::SwitchMode(PSM_ENTER_COMMAND);
CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text);
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_COMMAND);

View File

@ -652,8 +652,8 @@ private:
{
if (!this->groups.NeedRebuild()) return;
this->groups.Clear();
this->indents.Clear();
this->groups.clear();
this->indents.clear();
if (this->livery_class >= LC_GROUP_RAIL) {
GUIGroupList list;

View File

@ -77,14 +77,6 @@ public:
std::vector<T>::operator=(other);
}
/**
* Remove all items from the list.
*/
inline void Clear()
{
std::vector<T>::clear();
}
/**
* Remove all items from the list and free allocated memory.
*/

View File

@ -1949,7 +1949,7 @@ void LoadUnloadStation(Station *st)
for (Industry **iid = _cargo_delivery_destinations.Begin(); iid != isend; iid++) {
TriggerIndustryProduction(*iid);
}
_cargo_delivery_destinations.Clear();
_cargo_delivery_destinations.clear();
}
/**

View File

@ -487,7 +487,7 @@ StringID Engine::GetAircraftTypeText() const
*/
void EngineOverrideManager::ResetToDefaultMapping()
{
this->Clear();
this->clear();
for (VehicleType type = VEH_TRAIN; type <= VEH_AIRCRAFT; type++) {
for (uint internal_id = 0; internal_id < _engine_counts[type]; internal_id++) {
EngineIDMapping *eid = this->Append();

View File

@ -185,7 +185,7 @@ public:
/** Remove all items from the list. */
inline void Clear()
{
this->files.Clear();
this->files.clear();
}
/** Compact the list down to the smallest block size boundary. */

View File

@ -61,7 +61,7 @@ void LoadCheckData::Clear()
for (CompanyPropertiesMap::iterator it = this->companies.Begin(); it != end; it++) {
delete it->second;
}
companies.Clear();
companies.clear();
GamelogFree(this->gamelog_action, this->gamelog_actions);
this->gamelog_action = NULL;

View File

@ -600,7 +600,7 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, const char *&str,
Font *f = Layouter::GetFont(state.fontsize, state.cur_colour);
line.buffer = buff_begin;
fontMapping.Clear();
fontMapping.clear();
/*
* Go through the whole string while adding Font instances to the font map
@ -847,7 +847,7 @@ void Layouter::ResetFontCache(FontSize size)
for (FontColourMap::iterator it = fonts[size].Begin(); it != fonts[size].End(); ++it) {
delete it->second;
}
fonts[size].Clear();
fonts[size].clear();
/* We must reset the linecache since it references the just freed fonts */
ResetLineCache();

View File

@ -1136,7 +1136,7 @@ private:
{
if (!this->companies.NeedRebuild()) return;
this->companies.Clear();
this->companies.clear();
const Company *c;
FOR_ALL_COMPANIES(c) {

View File

@ -167,8 +167,8 @@ private:
{
if (!this->groups.NeedRebuild()) return;
this->groups.Clear();
this->indents.Clear();
this->groups.clear();
this->indents.clear();
GUIGroupList list;

View File

@ -273,7 +273,7 @@ void HotkeyList::Load(IniFile *ini)
for (Hotkey *hotkey = this->items; hotkey->name != NULL; ++hotkey) {
IniItem *item = group->GetItem(hotkey->name, false);
if (item != NULL) {
hotkey->keycodes.Clear();
hotkey->keycodes.clear();
if (item->value != NULL) ParseHotkeys(hotkey, item->value);
}
}

View File

@ -1202,7 +1202,7 @@ protected:
void BuildSortIndustriesList()
{
if (this->industries.NeedRebuild()) {
this->industries.Clear();
this->industries.clear();
const Industry *i;
FOR_ALL_INDUSTRIES(i) {
@ -2414,7 +2414,7 @@ struct IndustryCargoesWindow : public Window {
_displayed_industries.reset();
_displayed_industries.set(it);
this->fields.Clear();
this->fields.clear();
CargoesRow *row = this->fields.Append();
row->columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS);
row->columns[1].MakeEmpty(CFT_SMALL_EMPTY);
@ -2492,7 +2492,7 @@ struct IndustryCargoesWindow : public Window {
this->ind_cargo = cid + NUM_INDUSTRYTYPES;
_displayed_industries.reset();
this->fields.Clear();
this->fields.clear();
CargoesRow *row = this->fields.Append();
row->columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS);
row->columns[1].MakeEmpty(CFT_SMALL_EMPTY);

View File

@ -164,7 +164,7 @@ public:
for (SocketList::iterator s = sockets.Begin(); s != sockets.End(); s++) {
closesocket(s->second);
}
sockets.Clear();
sockets.clear();
DEBUG(net, 1, "[%s] closed listeners", Tsocket::GetName());
}
};

View File

@ -62,7 +62,7 @@ void NetworkUDPSocketHandler::Close()
for (SocketList::iterator s = this->sockets.Begin(); s != this->sockets.End(); s++) {
closesocket(s->second);
}
this->sockets.Clear();
this->sockets.clear();
}
NetworkRecvStatus NetworkUDPSocketHandler::CloseConnection(bool error)

View File

@ -981,7 +981,7 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci)
if (c->state != ContentInfo::AUTOSELECTED) continue;
/* Only unselect when WE are the only parent. */
parents.Clear();
parents.clear();
this->ReverseLookupDependency(parents, c);
/* First check whether anything depends on us */
@ -1000,7 +1000,7 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci)
if (force_selection) continue;
/* "Flood" search to find all items in the dependency graph*/
parents.Clear();
parents.clear();
this->ReverseLookupTreeDependency(parents, c);
/* Is there anything that is "force" selected?, if so... we're done. */
@ -1033,8 +1033,8 @@ void ClientNetworkContentSocketHandler::Clear()
{
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) delete *iter;
this->infos.Clear();
this->requested.Clear();
this->infos.clear();
this->requested.clear();
}
/*** CALLBACK ***/

View File

@ -385,7 +385,7 @@ class NetworkContentListWindow : public Window, ContentCallback {
if (!this->content.NeedRebuild()) return;
/* Create temporary array of games to use for listing */
this->content.Clear();
this->content.clear();
bool all_available = true;

View File

@ -250,7 +250,7 @@ protected:
if (!this->servers.NeedRebuild()) return;
/* Create temporary array of games to use for listing */
this->servers.Clear();
this->servers.clear();
for (NetworkGameList *ngl = _network_game_list; ngl != NULL; ngl = ngl->next) {
*this->servers.Append() = ngl;

View File

@ -668,7 +668,7 @@ void NetworkUDPInitialize()
GetBindAddresses(&server, _settings_client.network.server_port);
_udp_server_socket = new ServerNetworkUDPSocketHandler(&server);
server.Clear();
server.clear();
GetBindAddresses(&server, 0);
_udp_master_socket = new MasterNetworkUDPSocketHandler(&server);

View File

@ -1906,7 +1906,7 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte
if (_cur.skip_sprites < 0) return CIR_DISABLED;
static SmallVector<DrawTileSeqStruct, 8> tmp_layout;
tmp_layout.Clear();
tmp_layout.clear();
for (;;) {
/* no relative bounding box support */
DrawTileSeqStruct *dtss = tmp_layout.Append();
@ -2591,7 +2591,7 @@ static ChangeInfoResult LoadTranslationTable(uint gvid, int numinfo, ByteReader
return CIR_INVALID_ID;
}
translation_table.Clear();
translation_table.clear();
for (int i = 0; i < numinfo; i++) {
uint32 item = buf->ReadDWord();
*translation_table.Append() = BSWAP32(item);
@ -4791,7 +4791,7 @@ static void NewSpriteGroup(ByteReader *buf)
}
static SmallVector<DeterministicSpriteGroupAdjust, 16> adjusts;
adjusts.Clear();
adjusts.clear();
/* Loop through the var adjusts. Unfortunately we don't know how many we have
* from the outset, so we shall have to keep reallocing. */
@ -8246,7 +8246,7 @@ static void ResetNewGRF()
delete *file;
}
_grf_files.Clear();
_grf_files.clear();
_cur.grffile = NULL;
}
@ -9332,7 +9332,7 @@ static void AfterLoadGRFs()
for (StringIDMapping *it = _string_to_grf_mapping.Begin(); it != _string_to_grf_mapping.End(); it++) {
*it->target = MapGRFStringID(it->grfid, it->source);
}
_string_to_grf_mapping.Clear();
_string_to_grf_mapping.clear();
/* Free the action 6 override sprites. */
for (GRFLineToSpriteOverride::iterator it = _grf_line_to_action6_sprite_override.begin(); it != _grf_line_to_action6_sprite_override.end(); it++) {

View File

@ -661,7 +661,7 @@ void NewGRFSpriteLayout::AllocateRegisters()
*/
uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage, bool separate_ground) const
{
result_seq.Clear();
result_seq.clear();
uint32 var10_values = 0;
/* Create a copy of the spritelayout, so we can modify some values.

View File

@ -1456,7 +1456,7 @@ private:
{
if (!this->avails.NeedRebuild()) return;
this->avails.Clear();
this->avails.clear();
for (const GRFConfig *c = _all_grfs; c != NULL; c = c->next) {
bool found = false;

View File

@ -40,7 +40,7 @@ SoundEntry *AllocateSound(uint num)
void InitializeSoundPool()
{
_sounds.Clear();
_sounds.clear();
/* Copy original sound data to the pool */
SndCopyToPool();

View File

@ -167,7 +167,7 @@ RailType AllocateRailType(RailTypeLabel label)
/* Set up new rail type */
*rti = _original_railtypes[RAILTYPE_RAIL];
rti->label = label;
rti->alternate_labels.Clear();
rti->alternate_labels.clear();
/* Make us compatible with ourself. */
rti->powered_railtypes = (RailTypes)(1LL << rt);

View File

@ -2942,7 +2942,7 @@ bool AfterLoadGame()
SmallVector<uint, 16> skip_frames;
FOR_ALL_ROADVEHICLES(v) {
if (!v->IsFrontEngine()) continue;
skip_frames.Clear();
skip_frames.clear();
TileIndex prev_tile = v->tile;
uint prev_tile_skip = 0;
uint cur_skip = 0;

View File

@ -48,7 +48,7 @@ static void Load_ANIT()
}
uint count = (uint)SlGetFieldLength() / sizeof(*_animated_tiles.Begin());
_animated_tiles.Clear();
_animated_tiles.clear();
_animated_tiles.Append(count);
SlArray(_animated_tiles.Begin(), count, SLE_UINT32);
}

View File

@ -187,7 +187,7 @@ static void Save_EIDS()
static void Load_EIDS()
{
_engine_mngr.Clear();
_engine_mngr.clear();
while (SlIterateArray() != -1) {
EngineIDMapping *eid = _engine_mngr.Append();

View File

@ -81,7 +81,7 @@ void AfterLoadLabelMaps()
}
}
_railtype_list.Clear();
_railtype_list.clear();
}
/** Container for a label for SaveLoad system */
@ -108,7 +108,7 @@ static void Save_RAIL()
static void Load_RAIL()
{
_railtype_list.Clear();
_railtype_list.clear();
LabelObject lo;

View File

@ -172,7 +172,7 @@ static const SaveLoad _old_waypoint_desc[] = {
static void Load_WAYP()
{
/* Precaution for when loading failed and it didn't get cleared */
_old_waypoints.Clear();
_old_waypoints.clear();
int index;
@ -201,7 +201,7 @@ static void Ptrs_WAYP()
* whether we're in the NULL or "normal" Ptrs proc. So just clear the list
* of old waypoints we constructed and then this waypoint (and the other
* possibly corrupt ones) will not be queried in the NULL Ptrs proc run. */
_old_waypoints.Clear();
_old_waypoints.clear();
SlErrorCorrupt("Referencing invalid Town");
}
wp->town = Town::Get(wp->town_index);

View File

@ -103,7 +103,7 @@ public:
/** Clear the temporary storage. */
void Clear()
{
this->output_buffer.Clear();
this->output_buffer.clear();
}
/**

View File

@ -60,7 +60,7 @@ struct SignList {
DEBUG(misc, 3, "Building sign list");
this->signs.Clear();
this->signs.clear();
const Sign *si;
FOR_ALL_SIGNS(si) *this->signs.Append() = si;

View File

@ -178,7 +178,7 @@ protected:
DEBUG(misc, 3, "Building station list for company %d", owner);
this->stations.Clear();
this->stations.clear();
const Station *st;
FOR_ALL_STATIONS(st) {
@ -2173,8 +2173,8 @@ static const T *FindStationsNearby(TileArea ta, bool distant_join)
{
TileArea ctx = ta;
_stations_nearby_list.Clear();
_deleted_stations_nearby.Clear();
_stations_nearby_list.clear();
_deleted_stations_nearby.clear();
/* Check the inside, to return, if we sit on another station */
TILE_AREA_LOOP(t, ta) {

View File

@ -52,7 +52,7 @@ protected:
void BuildStoryPageList()
{
if (this->story_pages.NeedRebuild()) {
this->story_pages.Clear();
this->story_pages.clear();
const StoryPage *p;
FOR_ALL_STORY_PAGES(p) {
@ -78,7 +78,7 @@ protected:
void BuildStoryPageElementList()
{
if (this->story_page_elements.NeedRebuild()) {
this->story_page_elements.Clear();
this->story_page_elements.clear();
const StoryPage *p = GetSelPage();
if (p != NULL) {

View File

@ -1046,7 +1046,7 @@ void LanguageWriter::WriteLang(const StringData &data)
this->WriteLength(buffer.Length());
this->Write(buffer.Begin(), buffer.Length());
buffer.Clear();
buffer.clear();
}
}
}

View File

@ -652,8 +652,8 @@ public:
* for word break iterators (especially for CJK languages) in combination
* with UTF-8 input. As a work around we have to convert the input to
* UTF-16 and create a mapping back to UTF-8 character indices. */
this->utf16_str.Clear();
this->utf16_to_utf8.Clear();
this->utf16_str.clear();
this->utf16_to_utf8.clear();
while (*s != '\0') {
size_t idx = s - string_base;

View File

@ -319,7 +319,7 @@ static void Xunzip(byte **bufp, size_t *sizep)
{
if (textfile == NULL) return;
this->lines.Clear();
this->lines.clear();
/* Get text from file */
size_t filesize;

View File

@ -3469,7 +3469,7 @@ void SetTownRatingTestMode(bool mode)
static int ref_count = 0; // Number of times test-mode is switched on.
if (mode) {
if (ref_count == 0) {
_town_test_ratings.Clear();
_town_test_ratings.clear();
}
ref_count++;
} else {

View File

@ -650,7 +650,7 @@ private:
void BuildSortTownList()
{
if (this->towns.NeedRebuild()) {
this->towns.Clear();
this->towns.clear();
const Town *t;
FOR_ALL_TOWNS(t) {

View File

@ -263,7 +263,7 @@ static void TrainDetailsCapacityTab(const CargoSummaryItem *item, int left, int
*/
static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *summary)
{
summary->Clear();
summary->clear();
do {
if (!v->GetEngine()->CanCarryCargo()) continue;

View File

@ -942,7 +942,7 @@ static void RunVehicleDayProc()
void CallVehicleTicks()
{
_vehicles_to_autoreplace.Clear();
_vehicles_to_autoreplace.clear();
RunVehicleDayProc();

View File

@ -347,7 +347,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
}
static SmallVector<RefitResult, 16> refit_result;
refit_result.Clear();
refit_result.clear();
v->InvalidateNewGRFCacheOfChain();
byte actual_subtype = new_subtype;
@ -442,7 +442,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
}
}
refit_result.Clear();
refit_result.clear();
_returned_refit_capacity = total_capacity;
_returned_mail_refit_capacity = total_mail_capacity;
return cost;

View File

@ -234,7 +234,7 @@ byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_t
/* Create a list of subtypes used by the various parts of v_for */
static SmallVector<StringID, 4> subtypes;
subtypes.Clear();
subtypes.clear();
for (; v_from != NULL; v_from = v_from->HasArticulatedPart() ? v_from->GetNextArticulatedPart() : NULL) {
const Engine *e_from = v_from->GetEngine();
if (!e_from->CanCarryCargo() || !HasBit(e_from->info.callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) continue;
@ -406,7 +406,7 @@ struct RefitWindow : public Window {
*/
void BuildRefitList()
{
for (uint i = 0; i < NUM_CARGO; i++) this->list[i].Clear();
for (uint i = 0; i < NUM_CARGO; i++) this->list[i].clear();
Vehicle *v = Vehicle::Get(this->window_number);
/* Check only the selected vehicles. */

View File

@ -70,8 +70,8 @@ bool VehicleListIdentifier::UnpackIfValid(uint32 data)
*/
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engines, VehicleList *wagons, bool individual_wagons)
{
engines->Clear();
if (wagons != NULL && wagons != engines) wagons->Clear();
engines->clear();
if (wagons != NULL && wagons != engines) wagons->clear();
const Vehicle *v;
FOR_ALL_VEHICLES(v) {
@ -115,7 +115,7 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine
*/
bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli)
{
list->Clear();
list->clear();
const Vehicle *v;

View File

@ -1620,11 +1620,11 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom
_cur_dpi = old_dpi;
_vd.string_sprites_to_draw.Clear();
_vd.tile_sprites_to_draw.Clear();
_vd.parent_sprites_to_draw.Clear();
_vd.parent_sprites_to_sort.Clear();
_vd.child_screen_sprites_to_draw.Clear();
_vd.string_sprites_to_draw.clear();
_vd.tile_sprites_to_draw.clear();
_vd.parent_sprites_to_draw.clear();
_vd.parent_sprites_to_sort.clear();
_vd.child_screen_sprites_to_draw.clear();
}
/**

View File

@ -3024,7 +3024,7 @@ void HandleMouseEvents()
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
_newgrf_debug_sprite_picker.clicked_pixel = blitter->MoveTo(_screen.dst_ptr, _cursor.pos.x, _cursor.pos.y);
_newgrf_debug_sprite_picker.click_time = _realtime_tick;
_newgrf_debug_sprite_picker.sprites.Clear();
_newgrf_debug_sprite_picker.sprites.clear();
_newgrf_debug_sprite_picker.mode = SPM_REDRAW;
MarkWholeScreenDirty();
} else {
@ -3255,7 +3255,7 @@ void Window::ProcessScheduledInvalidations()
for (int *data = this->scheduled_invalidation_data.Begin(); this->window_class != WC_INVALID && data != this->scheduled_invalidation_data.End(); data++) {
this->OnInvalidateData(*data, true);
}
this->scheduled_invalidation_data.Clear();
this->scheduled_invalidation_data.clear();
}
/**