changeset 13224:194a605c55ab draft

(svn r17731) -Codechange: do not cache a boolean which states whether some other variable is not 0.
author rubidium <rubidium@openttd.org>
date Tue, 06 Oct 2009 21:12:35 +0000
parents 3708f1006de8
children a90c47f6d7f0
files src/cargopacket.cpp src/cargopacket.h
diffstat 2 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -78,7 +78,7 @@
 
 void CargoList::AgeCargo()
 {
-	if (this->empty) return;
+	if (this->Empty()) return;
 
 	uint dit = 0;
 	for (List::const_iterator it = this->packets.begin(); it != this->packets.end(); it++) {
@@ -214,12 +214,11 @@
 
 void CargoList::InvalidateCache()
 {
-	this->empty = this->packets.empty();
 	this->count = 0;
 	this->feeder_share = 0;
 	this->days_in_transit = 0;
 
-	if (this->empty) return;
+	if (this->packets.empty()) return;
 
 	uint dit = 0;
 	for (List::const_iterator it = this->packets.begin(); it != this->packets.end(); it++) {
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -163,7 +163,6 @@
 private:
 	List packets;         ///< The cargo packets in this list
 
-	bool empty;           ///< Cache for whether this list is empty or not
 	uint count;           ///< Cache for the number of cargo entities
 	Money feeder_share;   ///< Cache for the feeder share
 	uint days_in_transit; ///< Cache for the number of days in transit
@@ -197,7 +196,7 @@
 	 */
 	FORCEINLINE bool Empty() const
 	{
-		return this->empty;
+		return this->count == 0;
 	}
 
 	/**
@@ -224,7 +223,7 @@
 	 */
 	FORCEINLINE StationID Source() const
 	{
-		return this->Empty() ? INVALID_STATION : this->packets.front()->source;;
+		return this->Empty() ? INVALID_STATION : this->packets.front()->source;
 	}
 
 	/**