Changeset - r23530:3c94d05f840c
[Not reviewed]
master
0 11 0
Henry Wilson - 6 years ago 2018-09-25 20:20:24
m3henry@googlemail.com
Codechange: Replaced SmallVector::Get() const with std alternatives
11 files changed with 25 insertions and 38 deletions:
0 comments (0 inline, 0 general)
src/bridge_gui.cpp
Show inline comments
 
@@ -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);
 

	
src/core/smallvec_type.hpp
Show inline comments
 
@@ -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;
 
	}
 
};
 

	
 

	
src/fios.h
Show inline comments
 
@@ -156,7 +156,7 @@ public:
 
	 */
 
	inline const FiosItem *Get(uint index) const
 
	{
 
		return this->files.Get(index);
 
		return this->files.data() + index;
 
	}
 

	
 
	/**
src/gfx_layout.cpp
Show inline comments
 
@@ -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::FallbackLin
 
 */
 
const ParagraphLayouter::VisualRun *FallbackParagraphLayout::FallbackLine::GetVisualRun(int run) const
 
{
 
	return *this->Get(run);
 
	return this->at(run);
 
}
 

	
 
/**
src/network/network_content.h
Show inline comments
 
@@ -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(); }
 

	
src/network/network_content_gui.cpp
Show inline comments
 
@@ -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();
src/newgrf_engine.cpp
Show inline comments
 
@@ -1209,17 +1209,17 @@ void AlterVehicleListOrder(EngineID engi
 
 */
 
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);
src/openttd.cpp
Show inline comments
 
@@ -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++;
src/os/macosx/string_osx.cpp
Show inline comments
 
@@ -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
 
		{
src/os/windows/string_uniscribe.cpp
Show inline comments
 
@@ -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
 
		{
src/viewport.cpp
Show inline comments
 
@@ -1468,7 +1468,7 @@ static void ViewportDrawParentSprites(co
 

	
 
		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);
 
		}
0 comments (0 inline, 0 general)