Changeset - r7496:599894acf9bc
[Not reviewed]
master
0 12 0
rubidium - 17 years ago 2007-08-30 20:40:33
rubidium@openttd.org
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
12 files changed with 23 insertions and 47 deletions:
0 comments (0 inline, 0 general)
src/cargopacket.h
Show inline comments
 
@@ -43,7 +43,7 @@ struct CargoPacket : PoolItem<CargoPacke
 
	 * Is this a valid cargo packet ?
 
	 * @return true if and only it is valid
 
	 */
 
	bool IsValid() const { return this->count != 0; }
 
	inline bool IsValid() const { return this->count != 0; }
 

	
 
	/**
 
	 * Checks whether the cargo packet is from (exactly) the same source
src/depot.h
Show inline comments
 
@@ -23,7 +23,7 @@ struct Depot : PoolItem<Depot, DepotID, 
 
	Depot(TileIndex xy = 0) : xy(xy) {}
 
	~Depot();
 

	
 
	bool IsValid() const { return this->xy != 0; }
 
	inline bool IsValid() const { return this->xy != 0; }
 
};
 

	
 
static inline bool IsValidDepotID(DepotID index)
src/engine.h
Show inline comments
 
@@ -284,7 +284,7 @@ struct EngineRenew : PoolItem<EngineRene
 
	EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to), next(NULL) {}
 
	~EngineRenew() { this->from = INVALID_ENGINE; }
 

	
 
	bool IsValid() const { return this->from != INVALID_ENGINE; }
 
	inline bool IsValid() const { return this->from != INVALID_ENGINE; }
 
};
 

	
 
#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->IsValid())
src/industry.h
Show inline comments
 
@@ -123,7 +123,7 @@ struct Industry : PoolItem<Industry, Ind
 
	Industry(TileIndex tile = 0) : xy(tile) {}
 
	~Industry();
 

	
 
	bool IsValid() const { return this->xy != 0; }
 
	inline bool IsValid() const { return this->xy != 0; }
 
};
 

	
 
struct IndustryTileTable {
src/oldpool.h
Show inline comments
 
@@ -225,15 +225,6 @@ struct PoolItem {
 
	{
 
	}
 

	
 
	/**
 
	 * Is this a valid object or not?
 
	 * @return true if and only if it is valid
 
	 */
 
	virtual bool IsValid() const
 
	{
 
		return false;
 
	}
 

	
 
private:
 
	/**
 
	 * Allocate a pool item; possibly allocate a new block in the pool.
src/order.h
Show inline comments
 
@@ -107,7 +107,11 @@ struct Order : PoolItem<Order, OrderID, 
 
	Order() : refit_cargo(CT_NO_REFIT) {}
 
	~Order() { this->type = OT_NOTHING; }
 

	
 
	bool IsValid() const;
 
	/**
 
	 * Check if a Order really exists.
 
	 */
 
	inline bool IsValid() const { return this->type != OT_NOTHING; }
 

	
 
	void Free();
 
	void FreeChain();
 
};
 
@@ -140,14 +144,6 @@ static inline VehicleOrderID GetNumOrder
 
	return GetOrderPoolSize();
 
}
 

	
 
/**
 
 * Check if a Order really exists.
 
 */
 
inline bool Order::IsValid() const
 
{
 
	return this->type != OT_NOTHING;
 
}
 

	
 
inline void Order::Free()
 
{
 
	this->type  = OT_NOTHING;
src/signs.h
Show inline comments
 
@@ -26,7 +26,7 @@ struct Sign : PoolItem<Sign, SignID, &_S
 
	/** Destroy the sign */
 
	~Sign();
 

	
 
	bool IsValid() const { return this->str != STR_NULL; }
 
	inline bool IsValid() const { return this->str != STR_NULL; }
 
};
 

	
 
enum {
src/station.cpp
Show inline comments
 
@@ -237,14 +237,6 @@ bool Station::IsBuoy() const
 
	return (had_vehicle_of_type & HVOT_BUOY) != 0;
 
}
 

	
 
/** Determines whether a station exists
 
 * @todo replace 0 by INVALID_TILE
 
 */
 
bool Station::IsValid() const
 
{
 
	return xy != 0;
 
}
 

	
 

	
 
/************************************************************************/
 
/*                     StationRect implementation                       */
 
@@ -437,12 +429,6 @@ RoadStop::~RoadStop()
 
	xy = 0;
 
}
 

	
 
/** Determines whether a RoadStop is a valid (i.e. existing) one */
 
bool RoadStop::IsValid() const
 
{
 
	return xy != 0;
 
}
 

	
 
/** Checks whether there is a free bay in this road stop */
 
bool RoadStop::HasFreeBay() const
 
{
src/station.h
Show inline comments
 
@@ -65,7 +65,11 @@ struct RoadStop : PoolItem<RoadStop, Roa
 
	RoadStop(TileIndex tile = 0);
 
	virtual ~RoadStop();
 

	
 
	bool IsValid() const;
 
	/**
 
	 * Determines whether a road stop exists
 
	 * @return true if and only is the road stop exists
 
	 */
 
	inline bool IsValid() const { return this->xy != 0; }
 

	
 
	/* For accessing status */
 
	bool HasFreeBay() const;
 
@@ -175,7 +179,12 @@ public:
 
	uint GetPlatformLength(TileIndex tile, DiagDirection dir) const;
 
	uint GetPlatformLength(TileIndex tile) const;
 
	bool IsBuoy() const;
 
	bool IsValid() const;
 

	
 
	/**
 
	 * Determines whether a station exists
 
	 * @return true if and only is the station exists
 
	 */
 
	inline bool IsValid() const { return this->xy != 0; }
 
};
 

	
 
enum StationType {
src/town.h
Show inline comments
 
@@ -159,7 +159,7 @@ struct Town : PoolItem<Town, TownID, &_T
 
	/** Destroy the town */
 
	~Town();
 

	
 
	bool IsValid() const { return this->xy != 0; }
 
	inline bool IsValid() const { return this->xy != 0; }
 
};
 

	
 
struct HouseSpec {
src/waypoint.cpp
Show inline comments
 
@@ -418,12 +418,6 @@ Waypoint::~Waypoint()
 
	this->xy = 0;
 
}
 

	
 
bool Waypoint::IsValid() const
 
{
 
	return this->xy != 0;
 
}
 

	
 

	
 
/**
 
 * Fix savegames which stored waypoints in their old format
 
 */
src/waypoint.h
Show inline comments
 
@@ -30,7 +30,7 @@ struct Waypoint : PoolItem<Waypoint, Way
 
	Waypoint(TileIndex tile = 0);
 
	~Waypoint();
 

	
 
	bool IsValid() const;
 
	inline bool IsValid() const { return this->xy != 0; }
 
};
 

	
 
static inline bool IsValidWaypointID(WaypointID index)
0 comments (0 inline, 0 general)