diff options
author | Henry Wilson <m3henry@googlemail.com> | 2018-09-25 21:20:24 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2019-03-26 20:15:57 +0000 |
commit | 097328c3d73520834b4ef801945c4f57f9eca0cd (patch) | |
tree | b128c52ecba8fecc8bec436b5517faf0f976d5d2 /src | |
parent | aa7ca7fe64af51c2cd2400e3dec477dfbddadae3 (diff) | |
download | openttd-097328c3d73520834b4ef801945c4f57f9eca0cd.tar.xz |
Codechange: Replaced SmallVector::Get() const with std alternatives
Diffstat (limited to 'src')
-rw-r--r-- | src/bridge_gui.cpp | 14 | ||||
-rw-r--r-- | src/core/smallvec_type.hpp | 13 | ||||
-rw-r--r-- | src/fios.h | 2 | ||||
-rw-r--r-- | src/gfx_layout.cpp | 4 | ||||
-rw-r--r-- | src/network/network_content.h | 2 | ||||
-rw-r--r-- | src/network/network_content_gui.cpp | 6 | ||||
-rw-r--r-- | src/newgrf_engine.cpp | 12 | ||||
-rw-r--r-- | src/openttd.cpp | 4 | ||||
-rw-r--r-- | src/os/macosx/string_osx.cpp | 2 | ||||
-rw-r--r-- | src/os/windows/string_uniscribe.cpp | 2 | ||||
-rw-r--r-- | src/viewport.cpp | 2 |
11 files changed, 25 insertions, 38 deletions
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 0b4d0d619..bbb54551e 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -113,11 +113,11 @@ private: void BuildBridge(uint8 i) { switch ((TransportType)(this->type >> 15)) { - case TRANSPORT_RAIL: _last_railbridge_type = this->bridges->Get(i)->index; break; - case TRANSPORT_ROAD: _last_roadbridge_type = this->bridges->Get(i)->index; break; + case TRANSPORT_RAIL: _last_railbridge_type = this->bridges->at(i).index; break; + case TRANSPORT_ROAD: _last_roadbridge_type = this->bridges->at(i).index; break; default: break; } - DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->Get(i)->index, + DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->at(i).index, CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge); } @@ -187,10 +187,10 @@ public: Dimension sprite_dim = {0, 0}; // Biggest bridge sprite dimension Dimension text_dim = {0, 0}; // Biggest text dimension for (int i = 0; i < (int)this->bridges->size(); i++) { - const BridgeSpec *b = this->bridges->Get(i)->spec; + const BridgeSpec *b = this->bridges->at(i).spec; sprite_dim = maxdim(sprite_dim, GetSpriteSize(b->sprite)); - SetDParam(2, this->bridges->Get(i)->cost); + SetDParam(2, this->bridges->at(i).cost); SetDParam(1, b->speed); SetDParam(0, b->material); text_dim = maxdim(text_dim, GetStringBoundingBox(_game_mode == GM_EDITOR ? STR_SELECT_BRIDGE_SCENEDIT_INFO : STR_SELECT_BRIDGE_INFO)); @@ -227,9 +227,9 @@ public: case WID_BBS_BRIDGE_LIST: { uint y = r.top; for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges->size(); i++) { - const BridgeSpec *b = this->bridges->Get(i)->spec; + const BridgeSpec *b = this->bridges->at(i).spec; - SetDParam(2, this->bridges->Get(i)->cost); + SetDParam(2, this->bridges->at(i).cost); SetDParam(1, b->speed); SetDParam(0, b->material); diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp index a682697b3..1ec336b73 100644 --- a/src/core/smallvec_type.hpp +++ b/src/core/smallvec_type.hpp @@ -167,19 +167,6 @@ public: { return std::vector<T>::data() + std::vector<T>::size(); } - - /** - * Get the pointer to item "number" (const) - * - * @param index the position of the item - * @return the pointer to the item - */ - inline const T *Get(uint index) const - { - /* Allow access to the 'first invalid' item */ - assert(index <= std::vector<T>::size()); - return this->Begin() + index; - } }; diff --git a/src/fios.h b/src/fios.h index 0fe6fcc06..85b6b0dd6 100644 --- a/src/fios.h +++ b/src/fios.h @@ -156,7 +156,7 @@ public: */ inline const FiosItem *Get(uint index) const { - return this->files.Get(index); + return this->files.data() + index; } /** diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp index 7c4407e3a..786e07408 100644 --- a/src/gfx_layout.cpp +++ b/src/gfx_layout.cpp @@ -158,7 +158,7 @@ public: int GetLeading() const { return l->getLeading(); } int GetWidth() const { return l->getWidth(); } int CountRuns() const { return l->countRuns(); } - const ParagraphLayouter::VisualRun *GetVisualRun(int run) const { return *this->Get(run); } + const ParagraphLayouter::VisualRun *GetVisualRun(int run) const { return this->at(run); } int GetInternalCharLength(WChar c) const { @@ -458,7 +458,7 @@ int FallbackParagraphLayout::FallbackLine::CountRuns() const */ const ParagraphLayouter::VisualRun *FallbackParagraphLayout::FallbackLine::GetVisualRun(int run) const { - return *this->Get(run); + return this->at(run); } /** diff --git a/src/network/network_content.h b/src/network/network_content.h index a81cc6a6d..7cce7fc0a 100644 --- a/src/network/network_content.h +++ b/src/network/network_content.h @@ -133,7 +133,7 @@ public: /** Get the begin of the content inf iterator. */ ConstContentIterator Begin() const { return this->infos.Begin(); } /** Get the nth position of the content inf iterator. */ - ConstContentIterator Get(uint32 index) const { return this->infos.Get(index); } + ConstContentIterator Get(uint32 index) const { return this->infos.data() + index; } /** Get the end of the content inf iterator. */ ConstContentIterator End() const { return this->infos.End(); } diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 51215935c..109e63c95 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -641,7 +641,7 @@ public: int text_y_offset = WD_MATRIX_TOP + (line_height - FONT_HEIGHT_NORMAL) / 2; uint y = r.top; int cnt = 0; - for (ConstContentIterator iter = this->content.Get(this->vscroll->GetPosition()); iter != this->content.End() && cnt < this->vscroll->GetCapacity(); iter++, cnt++) { + for (ConstContentIterator iter = this->content.data() + this->vscroll->GetPosition(); iter != this->content.End() && cnt < this->vscroll->GetCapacity(); iter++, cnt++) { const ContentInfo *ci = *iter; if (ci == this->selected) GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1, PC_GREY); @@ -793,7 +793,7 @@ public: uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NCL_MATRIX); if (id_v >= this->content.size()) return; // click out of bounds - this->selected = *this->content.Get(id_v); + this->selected = this->content[id_v]; this->list_pos = id_v; const NWidgetBase *checkbox = this->GetWidget<NWidgetBase>(WID_NCL_CHECKBOX); @@ -923,7 +923,7 @@ public: return ES_HANDLED; } - this->selected = *this->content.Get(this->list_pos); + this->selected = this->content[this->list_pos]; if (this->UpdateFilterState()) { this->content.ForceRebuild(); diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index ce7cfdf24..07e0f8af7 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -1209,17 +1209,17 @@ void AlterVehicleListOrder(EngineID engine, uint target) */ static int CDECL EnginePreSort(const EngineID *a, const EngineID *b) { - const EngineIDMapping *id_a = _engine_mngr.Get(*a); - const EngineIDMapping *id_b = _engine_mngr.Get(*b); + const EngineIDMapping &id_a = _engine_mngr.at(*a); + const EngineIDMapping &id_b = _engine_mngr.at(*b); /* 1. Sort by engine type */ - if (id_a->type != id_b->type) return (int)id_a->type - (int)id_b->type; + if (id_a.type != id_b.type) return (int)id_a.type - (int)id_b.type; /* 2. Sort by scope-GRFID */ - if (id_a->grfid != id_b->grfid) return id_a->grfid < id_b->grfid ? -1 : 1; + if (id_a.grfid != id_b.grfid) return id_a.grfid < id_b.grfid ? -1 : 1; /* 3. Sort by local ID */ - return (int)id_a->internal_id - (int)id_b->internal_id; + return (int)id_a.internal_id - (int)id_b.internal_id; } /** @@ -1241,7 +1241,7 @@ void CommitVehicleListOrderChanges() EngineID source = it->engine; uint local_target = it->target; - const EngineIDMapping *id_source = _engine_mngr.Get(source); + const EngineIDMapping *id_source = _engine_mngr.data() + source; if (id_source->internal_id == local_target) continue; EngineID target = _engine_mngr.GetID(id_source->type, local_target, id_source->grfid); diff --git a/src/openttd.cpp b/src/openttd.cpp index b78084145..5478ec5a2 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1186,7 +1186,7 @@ static void CheckCaches() uint i = 0; FOR_ALL_TOWNS(t) { - if (MemCmpT(old_town_caches.Get(i), &t->cache) != 0) { + if (MemCmpT(old_town_caches.data() + i, &t->cache) != 0) { DEBUG(desync, 2, "town cache mismatch: town %i", (int)t->index); } i++; @@ -1202,7 +1202,7 @@ static void CheckCaches() i = 0; FOR_ALL_COMPANIES(c) { - if (MemCmpT(old_infrastructure.Get(i), &c->infrastructure) != 0) { + if (MemCmpT(old_infrastructure.data() + i, &c->infrastructure) != 0) { DEBUG(desync, 2, "infrastructure cache mismatch: company %i", (int)c->index); } i++; diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp index 4abf0037c..261885187 100644 --- a/src/os/macosx/string_osx.cpp +++ b/src/os/macosx/string_osx.cpp @@ -86,7 +86,7 @@ public: virtual int GetLeading() const; virtual int GetWidth() const; virtual int CountRuns() const { return this->size(); } - virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run); } + virtual const VisualRun *GetVisualRun(int run) const { return this->at(run); } int GetInternalCharLength(WChar c) const { diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp index 8877d36a6..f1c62c7d3 100644 --- a/src/os/windows/string_uniscribe.cpp +++ b/src/os/windows/string_uniscribe.cpp @@ -111,7 +111,7 @@ public: virtual int GetLeading() const; virtual int GetWidth() const; virtual int CountRuns() const { return this->size(); } - virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run); } + virtual const VisualRun *GetVisualRun(int run) const { return this->at(run); } int GetInternalCharLength(WChar c) const { diff --git a/src/viewport.cpp b/src/viewport.cpp index de0da81b2..5d6f58268 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1468,7 +1468,7 @@ static void ViewportDrawParentSprites(const ParentSpriteToSortVector *psd, const int child_idx = ps->first_child; while (child_idx >= 0) { - const ChildScreenSpriteToDraw *cs = csstdv->Get(child_idx); + const ChildScreenSpriteToDraw *cs = csstdv->data() + child_idx; child_idx = cs->next; DrawSpriteViewport(cs->image, cs->pal, ps->left + cs->x, ps->top + cs->y, cs->sub); } |