summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-08-30 20:40:33 +0000
committerrubidium <rubidium@openttd.org>2007-08-30 20:40:33 +0000
commit5ff81aca1873824af8b00eeb74ddedfce9dfef4a (patch)
tree1e96eadb775a124c36850f50c357f93af14e4be2
parentd4290086e800bfb66ac5a51ceabf57d058887559 (diff)
downloadopenttd-5ff81aca1873824af8b00eeb74ddedfce9dfef4a.tar.xz
(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.
-rw-r--r--src/cargopacket.h2
-rw-r--r--src/depot.h2
-rw-r--r--src/engine.h2
-rw-r--r--src/industry.h2
-rw-r--r--src/oldpool.h9
-rw-r--r--src/order.h14
-rw-r--r--src/signs.h2
-rw-r--r--src/station.cpp14
-rw-r--r--src/station.h13
-rw-r--r--src/town.h2
-rw-r--r--src/waypoint.cpp6
-rw-r--r--src/waypoint.h2
12 files changed, 23 insertions, 47 deletions
diff --git a/src/cargopacket.h b/src/cargopacket.h
index 2dacb7bc2..3fde1bacc 100644
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -43,7 +43,7 @@ struct CargoPacket : PoolItem<CargoPacket, CargoPacketID, &_CargoPacket_pool> {
* 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
diff --git a/src/depot.h b/src/depot.h
index 1b3de1b86..70a12d0bc 100644
--- a/src/depot.h
+++ b/src/depot.h
@@ -23,7 +23,7 @@ struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
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)
diff --git a/src/engine.h b/src/engine.h
index 6ee7d18c4..1ef09d3db 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -284,7 +284,7 @@ struct EngineRenew : PoolItem<EngineRenew, EngineRenewID, &_EngineRenew_pool> {
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())
diff --git a/src/industry.h b/src/industry.h
index c19dd83ae..265f2a333 100644
--- a/src/industry.h
+++ b/src/industry.h
@@ -123,7 +123,7 @@ struct Industry : PoolItem<Industry, IndustryID, &_Industry_pool> {
Industry(TileIndex tile = 0) : xy(tile) {}
~Industry();
- bool IsValid() const { return this->xy != 0; }
+ inline bool IsValid() const { return this->xy != 0; }
};
struct IndustryTileTable {
diff --git a/src/oldpool.h b/src/oldpool.h
index 9f79d632e..4ca9dbf07 100644
--- a/src/oldpool.h
+++ b/src/oldpool.h
@@ -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.
diff --git a/src/order.h b/src/order.h
index 987b36a0d..a9ccf383e 100644
--- a/src/order.h
+++ b/src/order.h
@@ -107,7 +107,11 @@ struct Order : PoolItem<Order, OrderID, &_Order_pool> {
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 GetNumOrders()
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;
diff --git a/src/signs.h b/src/signs.h
index 05af404eb..59f07d1ed 100644
--- a/src/signs.h
+++ b/src/signs.h
@@ -26,7 +26,7 @@ struct Sign : PoolItem<Sign, SignID, &_Sign_pool> {
/** Destroy the sign */
~Sign();
- bool IsValid() const { return this->str != STR_NULL; }
+ inline bool IsValid() const { return this->str != STR_NULL; }
};
enum {
diff --git a/src/station.cpp b/src/station.cpp
index 78bdf2121..d6d0f7a65 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -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
{
diff --git a/src/station.h b/src/station.h
index 5f48abec2..71abc5750 100644
--- a/src/station.h
+++ b/src/station.h
@@ -65,7 +65,11 @@ struct RoadStop : PoolItem<RoadStop, RoadStopID, &_RoadStop_pool> {
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 {
diff --git a/src/town.h b/src/town.h
index 6d5707146..7f196ccbf 100644
--- a/src/town.h
+++ b/src/town.h
@@ -159,7 +159,7 @@ struct Town : PoolItem<Town, TownID, &_Town_pool> {
/** Destroy the town */
~Town();
- bool IsValid() const { return this->xy != 0; }
+ inline bool IsValid() const { return this->xy != 0; }
};
struct HouseSpec {
diff --git a/src/waypoint.cpp b/src/waypoint.cpp
index 7383a2e9f..52eed75ed 100644
--- a/src/waypoint.cpp
+++ b/src/waypoint.cpp
@@ -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
*/
diff --git a/src/waypoint.h b/src/waypoint.h
index 4926d1313..46ffbc89e 100644
--- a/src/waypoint.h
+++ b/src/waypoint.h
@@ -30,7 +30,7 @@ struct Waypoint : PoolItem<Waypoint, WaypointID, &_Waypoint_pool> {
Waypoint(TileIndex tile = 0);
~Waypoint();
- bool IsValid() const;
+ inline bool IsValid() const { return this->xy != 0; }
};
static inline bool IsValidWaypointID(WaypointID index)