Codechange: Replaced SmallVector::Get(n) non-const with std::vector::data() + n

pull/82/head
Henry Wilson 6 years ago committed by PeterN
parent bc7dcaffca
commit aa7ca7fe64

@ -566,7 +566,7 @@ DEF_CONSOLE_CMD(ConUnBan)
seprintf(msg, lastof(msg), "Unbanned %s", _network_ban_list[index]);
IConsolePrint(CC_DEFAULT, msg);
free(_network_ban_list[index]);
_network_ban_list.Erase(_network_ban_list.Get(index));
_network_ban_list.erase(_network_ban_list.begin() + index);
} else {
IConsolePrint(CC_DEFAULT, "Invalid list index or IP not in ban-list.");
IConsolePrint(CC_DEFAULT, "For a list of banned IP's, see the command 'banlist'");

@ -180,19 +180,6 @@ public:
assert(index <= std::vector<T>::size());
return this->Begin() + index;
}
/**
* Get the pointer to item "number"
*
* @param index the position of the item
* @return the pointer to the item
*/
inline T *Get(uint index)
{
/* Allow access to the 'first invalid' item */
assert(index <= std::vector<T>::size());
return this->Begin() + index;
}
};

@ -344,6 +344,6 @@ void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, ui
if (num_items < 2) return;
assert(begin < el->size());
assert(begin + num_items <= el->size());
QSortT(el->Get(begin), num_items, compare);
QSortT(el->data() + begin, num_items, compare);
}

@ -165,7 +165,7 @@ public:
*/
inline FiosItem *Get(uint index)
{
return this->files.Get(index);
return this->files.data() + index;
}
inline const FiosItem &operator[](uint index) const

@ -139,7 +139,7 @@ void LinkGraph::RemoveNode(NodeID id)
node_edges[id] = node_edges[last_node];
}
Station::Get(this->nodes[last_node].station)->goods[this->cargo].node = id;
this->nodes.Erase(this->nodes.Get(id));
this->nodes.erase(this->nodes.begin() + id);
this->edges.EraseColumn(id);
/* Not doing EraseRow here, as having the extra invalid row doesn't hurt
* and removing it would trigger a lot of memmove. The data has already

@ -637,7 +637,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
/* Reserve the engine slot */
if (!static_access) {
EngineIDMapping *eid = _engine_mngr.Get(engine);
EngineIDMapping *eid = _engine_mngr.data() + engine;
eid->grfid = scope_grfid; // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation
}

@ -262,7 +262,7 @@ GRFParameterInfo::GRFParameterInfo(GRFParameterInfo &info) :
complete_labels(info.complete_labels)
{
for (uint i = 0; i < info.value_names.size(); i++) {
SmallPair<uint32, GRFText *> *data = info.value_names.Get(i);
SmallPair<uint32, GRFText *> *data = info.value_names.data() + i;
this->value_names.Insert(data->first, DuplicateGRFText(data->second));
}
}
@ -273,7 +273,7 @@ GRFParameterInfo::~GRFParameterInfo()
CleanUpGRFText(this->name);
CleanUpGRFText(this->desc);
for (uint i = 0; i < this->value_names.size(); i++) {
SmallPair<uint32, GRFText *> *data = this->value_names.Get(i);
SmallPair<uint32, GRFText *> *data = this->value_names.data() + i;
CleanUpGRFText(data->second);
}
}

@ -2133,7 +2133,7 @@ static bool AddNearbyStation(TileIndex tile, void *user_data)
/* First check if there were deleted stations here */
for (uint i = 0; i < _deleted_stations_nearby.size(); i++) {
TileAndStation *ts = _deleted_stations_nearby.Get(i);
TileAndStation *ts = _deleted_stations_nearby.data() + i;
if (ts->tile == tile) {
*_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
_deleted_stations_nearby.Erase(ts);

@ -50,7 +50,7 @@ TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, Text
}
if (i == _text_effects.size()) _text_effects.Append();
TextEffect *te = _text_effects.Get(i);
TextEffect *te = _text_effects.data() + i;
/* Start defining this object */
te->string_id = msg;
@ -69,7 +69,7 @@ TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, Text
void UpdateTextEffect(TextEffectID te_id, StringID msg)
{
/* Update details */
TextEffect *te = _text_effects.Get(te_id);
TextEffect *te = _text_effects.data() + te_id;
if (msg == te->string_id && GetDParam(0) == te->params_1) return;
te->string_id = msg;
te->params_1 = GetDParam(0);

Loading…
Cancel
Save