diff options
author | Henry Wilson <m3henry@googlemail.com> | 2018-09-25 21:01:56 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2019-03-26 20:15:57 +0000 |
commit | aa7ca7fe64af51c2cd2400e3dec477dfbddadae3 (patch) | |
tree | 2b80f868a6e3e9df699f3b96bffb41b7b6f84125 /src | |
parent | bc7dcaffca553b227fe895dc185e657d110c5ffe (diff) | |
download | openttd-aa7ca7fe64af51c2cd2400e3dec477dfbddadae3.tar.xz |
Codechange: Replaced SmallVector::Get(n) non-const with std::vector::data() + n
Diffstat (limited to 'src')
-rw-r--r-- | src/console_cmds.cpp | 2 | ||||
-rw-r--r-- | src/core/smallvec_type.hpp | 13 | ||||
-rw-r--r-- | src/engine_gui.cpp | 2 | ||||
-rw-r--r-- | src/fios.h | 2 | ||||
-rw-r--r-- | src/linkgraph/linkgraph.cpp | 2 | ||||
-rw-r--r-- | src/newgrf.cpp | 2 | ||||
-rw-r--r-- | src/newgrf_config.cpp | 4 | ||||
-rw-r--r-- | src/station_gui.cpp | 2 | ||||
-rw-r--r-- | src/texteff.cpp | 4 |
9 files changed, 10 insertions, 23 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index a4a6fccd1..85b2ddbb1 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -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'"); diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp index 81b9cf7ee..a682697b3 100644 --- a/src/core/smallvec_type.hpp +++ b/src/core/smallvec_type.hpp @@ -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; - } }; diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index c2a258f18..caf264e3d 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -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); } diff --git a/src/fios.h b/src/fios.h index 71a6cff17..0fe6fcc06 100644 --- a/src/fios.h +++ b/src/fios.h @@ -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 diff --git a/src/linkgraph/linkgraph.cpp b/src/linkgraph/linkgraph.cpp index eee7ac61f..532792e7c 100644 --- a/src/linkgraph/linkgraph.cpp +++ b/src/linkgraph/linkgraph.cpp @@ -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 diff --git a/src/newgrf.cpp b/src/newgrf.cpp index f80e79f7d..6ff991441 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -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 } diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index fa84c947a..730207c6b 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -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); } } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 36a58e62e..157d571af 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -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); diff --git a/src/texteff.cpp b/src/texteff.cpp index 41907e14d..92c201704 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -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); |